Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update __init__.py #197

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions py2pack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import warnings

import jinja2
import platformdirs
import pypi_search.search
import requests
from metaextract import utils as meta_utils
Expand Down Expand Up @@ -98,7 +99,7 @@ def _get_template_dirs():
is important. The first found template from the first found dir wins!"""
return filter(lambda x: os.path.exists(x), [
# user dir
os.path.join(os.path.expanduser('~'), '.py2pack', 'templates'),
os.path.join(platformdirs.user_config_dir(), '.py2pack', 'templates'),
# system wide dir
os.path.join('/', 'usr', 'share', 'py2pack', 'templates'),
# usually inside the site-packages dir
Expand Down Expand Up @@ -405,12 +406,13 @@ def generate(args):
outfile.close()


def fetch_data(args):
def fetch_local_data(args):
localfile = args.localfile
local = args.local

if not localfile and local:
localfile = f'{args.name}.egg-info/PKG-INFO'
localfile = os.path.join(f'{args.name}.egg-info', 'PKG-INFO')

if os.path.isfile(localfile):
try:
data = pypi_json_file(localfile)
Expand All @@ -419,6 +421,10 @@ def fetch_data(args):
args.fetched_data = data
args.version = args.fetched_data['info']['version']
return
fetch_data(args)


def fetch_data(args):
args.fetched_data = pypi_json(args.name, args.version)
urls = args.fetched_data['urls']
if len(urls) == 0:
Expand Down
Loading