Skip to content

Commit

Permalink
Packaging for PyPI as 0.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
jamalex committed Dec 2, 2018
1 parent b8f7700 commit d7f00b6
Show file tree
Hide file tree
Showing 17 changed files with 86 additions and 34 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
*.pyc
__pycache__
__pycache__
build/
dist/
*.egg-info
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2018 Jamie Alexandre

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ page.title = "The title has now changed, and has *live-updated* in the browser!"

# TODO

* Package for PyPI
* Support inline "user" and "page" links, and reminders, in markdown conversion
* Utilities to support updating/creating collection schemas
* Utilities to support updating/creating collection_view queries
Expand Down
Empty file added notion/__init__.py
Empty file.
13 changes: 6 additions & 7 deletions notion/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import requests
import uuid

from utils import extract_id, now, get_embed_link, get_embed_data, add_signed_prefix_as_needed, remove_signed_prefix_as_needed
from maps import property_map, field_map
from operations import build_operation
from settings import S3_URL_PREFIX
from records import Record
from .utils import extract_id, now, get_embed_link, get_embed_data, add_signed_prefix_as_needed, remove_signed_prefix_as_needed
from .maps import property_map, field_map
from .operations import build_operation
from .settings import S3_URL_PREFIX
from .records import Record


class Children(object):
Expand Down Expand Up @@ -525,13 +525,12 @@ def description(self, val):
self.collection.description = val

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


class CollectionViewPageBlock(CollectionViewBlock):

_type = "collection_view_page"
# TODO: add custom fields


class FramerBlock(EmbedBlock):
Expand Down
18 changes: 9 additions & 9 deletions notion/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
from requests.cookies import cookiejar_from_dict
from urllib.parse import urljoin

from utils import extract_id, now
from block import Block, BLOCK_TYPES
from collection import Collection, CollectionView, CollectionRowBlock, COLLECTION_VIEW_TYPES
from settings import API_BASE_URL
from operations import operation_update_last_edited, build_operation
from store import RecordStore
from user import User
from space import Space
from .utils import extract_id, now
from .block import Block, BLOCK_TYPES
from .collection import Collection, CollectionView, CollectionRowBlock, COLLECTION_VIEW_TYPES
from .settings import API_BASE_URL
from .operations import operation_update_last_edited, build_operation
from .store import RecordStore
from .user import User
from .space import Space


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

Expand Down
12 changes: 6 additions & 6 deletions notion/collection.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from datetime import datetime

from operations import build_operation
from records import Record
from maps import property_map, field_map
from block import Block, PageBlock
from utils import add_signed_prefix_as_needed, remove_signed_prefix_as_needed, slugify
from markdown import markdown_to_notion, notion_to_markdown
from .block import Block, PageBlock
from .maps import property_map, field_map
from .markdown import markdown_to_notion, notion_to_markdown
from .operations import build_operation
from .records import Record
from .utils import add_signed_prefix_as_needed, remove_signed_prefix_as_needed, slugify


class Collection(Record):
Expand Down
2 changes: 1 addition & 1 deletion notion/maps.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from markdown import markdown_to_notion, notion_to_markdown
from .markdown import markdown_to_notion, notion_to_markdown


def field_map(path, python_to_api=lambda x: x, api_to_python=lambda x: x):
Expand Down
1 change: 1 addition & 0 deletions notion/markdown.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import commonmark
import re

from commonmark.dump import prepare
from copy import deepcopy

Expand Down
2 changes: 1 addition & 1 deletion notion/operations.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from utils import now
from .utils import now


def build_operation(id, path, args, command="set", table="block"):
Expand Down
4 changes: 2 additions & 2 deletions notion/records.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from utils import extract_id
from operations import build_operation
from .utils import extract_id
from .operations import build_operation


class Record(object):
Expand Down
4 changes: 2 additions & 2 deletions notion/space.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from records import Record
from maps import property_map, field_map
from .records import Record
from .maps import property_map, field_map


class Space(Record):
Expand Down
3 changes: 2 additions & 1 deletion notion/store.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from collections import defaultdict
from utils import extract_id
from tzlocal import get_localzone

from .utils import extract_id


class Missing(object):

Expand Down
4 changes: 2 additions & 2 deletions notion/user.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from records import Record
from maps import property_map, field_map
from .records import Record
from .maps import property_map, field_map


class User(Record):
Expand Down
2 changes: 1 addition & 1 deletion notion/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from datetime import datetime
from slugify import slugify as _dash_slugify

from settings import BASE_URL, SIGNED_URL_PREFIX, S3_URL_PREFIX
from .settings import BASE_URL, SIGNED_URL_PREFIX, S3_URL_PREFIX


def now():
Expand Down
File renamed without changes.
30 changes: 30 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import setuptools

try: # for pip >= 10
from pip._internal.req import parse_requirements
except ImportError: # for pip <= 9.0.3
from pip.req import parse_requirements

with open("README.md", "r") as fh:
long_description = fh.read()

reqs = parse_requirements("requirements.txt", session=False)
install_requires = [str(ir.req) for ir in reqs]

setuptools.setup(
name="notion",
version="0.0.2",
author="Jamie Alexandre",
author_email="[email protected]",
description="Unofficial Python API client for Notion.so",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/jamalex/notion-py",
install_requires=install_requires,
packages=setuptools.find_packages(),
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
)

0 comments on commit d7f00b6

Please sign in to comment.