How to use get_pkg_info method in autotest

Best Python code snippet using autotest_python

core.py

Source:core.py Github

copy

Full Screen

...19 pkg = {20 'key': dist.key,21 'name': dist.project_name,22 'version': dist.version,23 'description': get_pkg_info(pkg_info, 'Summary'),24 'license': get_pkg_info(pkg_info, 'License'),25 'home_page': get_pkg_info(pkg_info, 'Home-page'),26 'is_editable': dist_is_editable(dist),27 'in_user_site': dist_in_usersite(dist),28 'in_global_site': not dist_is_local(dist),29 'requirements': {30 req.key: str(req.specifier) or None31 for req in dist.requires()32 },33 'issues': [],34 }35 return pkg36except ImportError:37 from pip._internal.utils.compat import stdlib_pkgs38 from pip._internal.metadata import get_default_environment, get_environment39 def get_installed_distributions(40 local_only = True,41 skip = stdlib_pkgs,42 include_editables = True,43 editables_only = False,44 user_only = False,45 paths = None,46 ):47 if paths is None:48 env = get_default_environment()49 else:50 env = get_environment(paths)51 dists = env.iter_installed_distributions(52 local_only=local_only,53 skip=skip,54 include_editables=include_editables,55 editables_only=editables_only,56 user_only=user_only,57 )58 return dists59 def make_package(dist):60 pkg_info = dist.metadata61 pkg = {62 'key': dist.canonical_name,63 'name': dist._dist.project_name,64 'version': str(dist.version),65 'description': get_pkg_info(pkg_info, 'Summary'),66 'license': get_pkg_info(pkg_info, 'License'),67 'home_page': get_pkg_info(pkg_info, 'Home-page'),68 'is_editable': dist.editable,69 'in_user_site': dist.in_usersite,70 'in_global_site': not dist.local,71 'requirements': {72 req.key: str(req.specifier) or None73 for req in dist._dist.requires()74 },75 'issues': [],76 }77 return pkg78def get_environment():79 env = {}80 version = get_distribution('envrpt').version81 env['analyzer'] = 'envrpt/%s' % (version,)82 env['date_analyzed'] = datetime.now()83 ver = sys.version_info84 env['python_version'] = '%s.%s.%s' % (ver.major, ver.minor, ver.micro)85 env['pip_version'] = pip_version86 env['platform'] = sys.platform87 env['runtime'] = sys.implementation.name88 ver = sys.implementation.version89 env['runtime_version'] = '%s.%s.%s' % (ver.major, ver.minor, ver.micro)90 env['base_directory'] = sys.prefix91 return env92def get_pkg_info(pkg_info, key):93 if key in pkg_info and pkg_info[key] != 'UNKNOWN':94 return pkg_info[key]95 return None96def get_packages():97 distributions = get_installed_distributions(98 local_only=False,99 include_editables=True,100 editables_only=False,101 user_only=False,102 )103 packages = {104 pkg['key']: pkg105 for pkg in [106 make_package(dist)...

Full Screen

Full Screen

pypi_top200.py

Source:pypi_top200.py Github

copy

Full Screen

...16def header():17 fmt = '{:30}{:13}{}'18 return '\n'.join((fmt.format('Module name', 'Latest', 'Python 3?'),19 fmt.format('=' * 11, '=' * 6, '=' * 9)))20def get_pkg_info(pkg_name, downloads=0):21 # multiple asyncio jobs can not share a client22 local_client = ServerProxy(PYPI_URL) if USE_ASYNCIO else client23 try:24 release = local_client.package_releases(pkg_name)[0]25 except IndexError: # marionette-transport, ll-orasql, and similar26 print(pkg_name, 'has no releases in PyPI!!')27 return pkg_info(pkg_name, downloads, 'PyPI error!!', False)28 release_data = local_client.release_data(pkg_name, release)29 py3 = py3_classifier in '\n'.join(release_data['classifiers'])30 return pkg_info(pkg_name, downloads, release, py3)31@asyncio.coroutine32def async_main(): # ~ 32 seconds for 200 packages on my MacBook Pro33 loop = asyncio.get_event_loop()34 futures = [loop.run_in_executor(None, get_pkg_info, pkg_name, downloads)35 for pkg_name, downloads in client.top_packages(MAX_PACKAGES)]36 return [(yield from fut) for fut in futures]37def sync_main():38 # as list for apples-to-apples benchmark - ~ 112 seconds39 # return [get_pkg_info(pkg_name, downloads) for pkg_name, downloads40 # in client.top_packages(MAX_PACKAGES)]41 # or as a generator for continuous output - ~ 105 seconds42 return (get_pkg_info(pkg_name, downloads) for pkg_name, downloads43 in client.top_packages(MAX_PACKAGES))44fmt = 'Gathering Python 3 support info on the top {} PyPI packages...'45print(fmt.format(MAX_PACKAGES))46start = time.time()47if USE_ASYNCIO:48 loop = asyncio.get_event_loop()49 packages_info = loop.run_until_complete(async_main())50else:51 packages_info = sync_main()52print(time.time() - start, 'seconds') # ~ 32 sec if USE_ASYNCIO else ~ 105 sec53print(header())54for package_info in packages_info:55 print(FMT.format(**package_info._asdict()))56losers = [pkg for pkg in packages_info if not pkg.py3]...

Full Screen

Full Screen

setup.py

Source:setup.py Github

copy

Full Screen

...3"""The setup script."""4import io5import os6from setuptools import setup, find_packages7def get_pkg_info(info_file, info):8 val = ""9 info_file.seek(0)10 for line in info_file:11 if line.startswith('__{}__'.format(info)):12 val = line.split("=")[1].replace("'", "").replace('"', "").strip()13 return val14with open(os.path.join('swmmnetwork', '__init__.py')) as init_file:15 author = get_pkg_info(init_file, 'author')16 email = get_pkg_info(init_file, 'email')17 version = get_pkg_info(init_file, 'version')18with open('README.rst') as readme_file:19 readme = readme_file.read()20with open('HISTORY.rst') as history_file:21 history = history_file.read()22requirements = [23 'networkx',24 'pandas',25 'numpy',26 'pint==0.8.1',27]28test_requirements = [29 'pytest',30]31package_data = {...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful