Skip to content

Commit

Permalink
Check domain/ext properly
Browse files Browse the repository at this point in the history
  • Loading branch information
tzizi committed Jul 25, 2018
1 parent c8c8408 commit 1889060
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions _ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from datetime import date, timedelta
from collections import OrderedDict
from functools import partial
import re
import urlparse

import yaml
from cyrax import events
Expand Down Expand Up @@ -87,8 +87,8 @@ def parse_item(entry, entry_tags=[], meta={}, meta_tags=[]):
tags=parse_tags(entry, entry_tags) + parse_tags(meta, meta_tags))

if "repo" in result:
domain = re.sub(r".*://([^/]*)/.*", "\\1", result["repo"])
ext = re.sub(r".*?(\.[^/]*)$", "\\1", result["repo"])
domain = urlparse.urlparse(result["repo"]).netloc
ext = os.path.splitext(result["repo"])[1]

if "github.com" in domain:
result["repoicon"] = "GitHub-Mark-32px.png"
Expand All @@ -107,9 +107,7 @@ def parse_item(entry, entry_tags=[], meta={}, meta_tags=[]):
elif "launchpad.net" in domain:
result["repoicon"] = "launchpad.png"
result["repotitle"] = "Launchpad"
elif (".zip" in ext or
".tar." in ext or
".tgz" in ext):
elif ext in (".zip", ".tar", ".tgz", ".tbz2", ".bz2", ".xz", ".rar"):
result["repoicon"] = "emblem-package.png"
result["repotitle"] = "Archive"

Expand Down

0 comments on commit 1889060

Please sign in to comment.