Skip to content

Commit d7f00b6

Browse files
committed
Packaging for PyPI as 0.0.2
1 parent b8f7700 commit d7f00b6

17 files changed

+86
-34
lines changed

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
*.pyc
2-
__pycache__
2+
__pycache__
3+
build/
4+
dist/
5+
*.egg-info

LICENSE

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2018 Jamie Alexandre
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ page.title = "The title has now changed, and has *live-updated* in the browser!"
4040

4141
# TODO
4242

43-
* Package for PyPI
4443
* Support inline "user" and "page" links, and reminders, in markdown conversion
4544
* Utilities to support updating/creating collection schemas
4645
* Utilities to support updating/creating collection_view queries

notion/__init__.py

Whitespace-only changes.

notion/block.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
import requests
55
import uuid
66

7-
from utils import extract_id, now, get_embed_link, get_embed_data, add_signed_prefix_as_needed, remove_signed_prefix_as_needed
8-
from maps import property_map, field_map
9-
from operations import build_operation
10-
from settings import S3_URL_PREFIX
11-
from records import Record
7+
from .utils import extract_id, now, get_embed_link, get_embed_data, add_signed_prefix_as_needed, remove_signed_prefix_as_needed
8+
from .maps import property_map, field_map
9+
from .operations import build_operation
10+
from .settings import S3_URL_PREFIX
11+
from .records import Record
1212

1313

1414
class Children(object):
@@ -525,13 +525,12 @@ def description(self, val):
525525
self.collection.description = val
526526

527527
def _str_fields(self):
528-
return super()._str_fields() + ["caption"]
528+
return super()._str_fields() + ["title", "collection"]
529529

530530

531531
class CollectionViewPageBlock(CollectionViewBlock):
532532

533533
_type = "collection_view_page"
534-
# TODO: add custom fields
535534

536535

537536
class FramerBlock(EmbedBlock):

notion/client.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
from requests.cookies import cookiejar_from_dict
77
from urllib.parse import urljoin
88

9-
from utils import extract_id, now
10-
from block import Block, BLOCK_TYPES
11-
from collection import Collection, CollectionView, CollectionRowBlock, COLLECTION_VIEW_TYPES
12-
from settings import API_BASE_URL
13-
from operations import operation_update_last_edited, build_operation
14-
from store import RecordStore
15-
from user import User
16-
from space import Space
9+
from .utils import extract_id, now
10+
from .block import Block, BLOCK_TYPES
11+
from .collection import Collection, CollectionView, CollectionRowBlock, COLLECTION_VIEW_TYPES
12+
from .settings import API_BASE_URL
13+
from .operations import operation_update_last_edited, build_operation
14+
from .store import RecordStore
15+
from .user import User
16+
from .space import Space
1717

1818

1919
class NotionClient(object):
@@ -93,7 +93,7 @@ def get_collection_view(self, url_or_id, collection=None, force_refresh=False):
9393
def refresh_records(self, **kwargs):
9494
"""
9595
The keyword arguments map table names into lists of (or singular) record IDs to load for that table.
96-
Use True to refresh all known records for that table.
96+
Use `True` instead of a list to refresh all known records for that table.
9797
"""
9898
self._store.call_get_record_values(**kwargs)
9999

notion/collection.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
from datetime import datetime
22

3-
from operations import build_operation
4-
from records import Record
5-
from maps import property_map, field_map
6-
from block import Block, PageBlock
7-
from utils import add_signed_prefix_as_needed, remove_signed_prefix_as_needed, slugify
8-
from markdown import markdown_to_notion, notion_to_markdown
3+
from .block import Block, PageBlock
4+
from .maps import property_map, field_map
5+
from .markdown import markdown_to_notion, notion_to_markdown
6+
from .operations import build_operation
7+
from .records import Record
8+
from .utils import add_signed_prefix_as_needed, remove_signed_prefix_as_needed, slugify
99

1010

1111
class Collection(Record):

notion/maps.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from markdown import markdown_to_notion, notion_to_markdown
1+
from .markdown import markdown_to_notion, notion_to_markdown
22

33

44
def field_map(path, python_to_api=lambda x: x, api_to_python=lambda x: x):

notion/markdown.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import commonmark
22
import re
3+
34
from commonmark.dump import prepare
45
from copy import deepcopy
56

notion/operations.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from utils import now
1+
from .utils import now
22

33

44
def build_operation(id, path, args, command="set", table="block"):

notion/records.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from utils import extract_id
2-
from operations import build_operation
1+
from .utils import extract_id
2+
from .operations import build_operation
33

44

55
class Record(object):

notion/space.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from records import Record
2-
from maps import property_map, field_map
1+
from .records import Record
2+
from .maps import property_map, field_map
33

44

55
class Space(Record):

notion/store.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from collections import defaultdict
2-
from utils import extract_id
32
from tzlocal import get_localzone
43

4+
from .utils import extract_id
5+
56

67
class Missing(object):
78

notion/user.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from records import Record
2-
from maps import property_map, field_map
1+
from .records import Record
2+
from .maps import property_map, field_map
33

44

55
class User(Record):

notion/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from datetime import datetime
77
from slugify import slugify as _dash_slugify
88

9-
from settings import BASE_URL, SIGNED_URL_PREFIX, S3_URL_PREFIX
9+
from .settings import BASE_URL, SIGNED_URL_PREFIX, S3_URL_PREFIX
1010

1111

1212
def now():
File renamed without changes.

setup.py

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import setuptools
2+
3+
try: # for pip >= 10
4+
from pip._internal.req import parse_requirements
5+
except ImportError: # for pip <= 9.0.3
6+
from pip.req import parse_requirements
7+
8+
with open("README.md", "r") as fh:
9+
long_description = fh.read()
10+
11+
reqs = parse_requirements("requirements.txt", session=False)
12+
install_requires = [str(ir.req) for ir in reqs]
13+
14+
setuptools.setup(
15+
name="notion",
16+
version="0.0.2",
17+
author="Jamie Alexandre",
18+
author_email="jamalex+python@gmail.com",
19+
description="Unofficial Python API client for Notion.so",
20+
long_description=long_description,
21+
long_description_content_type="text/markdown",
22+
url="https://github.com/jamalex/notion-py",
23+
install_requires=install_requires,
24+
packages=setuptools.find_packages(),
25+
classifiers=[
26+
"Programming Language :: Python :: 3",
27+
"License :: OSI Approved :: MIT License",
28+
"Operating System :: OS Independent",
29+
],
30+
)

0 commit comments

Comments
 (0)