Skip to content

Commit

Permalink
Fix more typing errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
yaph committed Oct 23, 2020
1 parent eee665d commit 9c98748
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions logya/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def content_type(path: Path) -> Union[None, str]:
return 'html'
if path.suffix in {'.md', '.markdown'}:
return 'markdown'
return None


def create_url(path: Path) -> str:
Expand Down
5 changes: 3 additions & 2 deletions logya/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ def __init__(self, dir_site: str = '.', verbose: bool = False):
for coll in self.collections.values():
coll['index'] = {}

# Initialize extensions
# Simplify access to these settings.
self.markdown_extensions = self.settings.get('extensions', {}).get('markdown', [])
self.languages = self.settings.get('languages', {})

def build(self):
"""Read content and initialize template environment."""
Expand Down Expand Up @@ -82,7 +83,7 @@ def update_collections(self, doc: dict):
url = f'/{coll["path"]}/{slugify(value).lower()}/'

# Prepend language code to URL if language is specified in doc and exists in configuration.
if 'language' in doc and doc['language'] in self.settings.get('languages'):
if 'language' in doc and doc['language'] in self.languages:
url = f'/{doc["language"]}{url}'

if url in self.doc_index:
Expand Down
2 changes: 1 addition & 1 deletion logya/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
class HTTPRequestHandler(http.server.SimpleHTTPRequestHandler):
"""SimpleHTTPRequestHandler based class to return resources."""

L = None
L: Logya

def __init__(self, *args):
super(HTTPRequestHandler, self).__init__(*args, directory=self.L.paths.public.as_posix())
Expand Down
3 changes: 2 additions & 1 deletion logya/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
try:
from yaml import CDumper as Dumper, CLoader as Loader
except ImportError:
from yaml import Dumper, Loader
from yaml import Dumper, Loader # type: ignore


# Characters not to be used in URLs, allowing some punctuation.
Expand Down Expand Up @@ -47,6 +47,7 @@ def get_item(items: list, value: str, attr: str = 'url') -> Union[dict, None]:
for item in items:
if item.get(attr) == value:
return item
return None


def load_yaml(text: str) -> dict:
Expand Down

0 comments on commit 9c98748

Please sign in to comment.