Saravanan666/pypi-org huggingface dataset:
Package: import_file
import_fileimport_file is meant to import a python script from a normal file path.
Relative (dotted) imports are complicated, and fixing sys.path just feels wrong.Usage examples:>>>from import_file import import_file
>>>mylib = import_file('c:\mylib.py')
>>>another = import_file('relative_subdir/another.py')So now you aren’t limited to importing only within your package or trail of
__init__.py files.This should work for python 2.5-3.2 and it’s public domain, have fun.http://uberpython.wordpress.comhttp://code.google.com/p/import-file/http://pypi.python.org/pypi/import_fileubershmekel at gmail
Package: importfiler
importfilerProfile your imports, find what is dragging your module load time.importfilerbuilds on top of the output generated by the interpreter-X importtimetraces.
It is just a different output targeted more at a specific use-case. Finding what modules impact
the longest on a specific one you are trying to optimize.If you need a more detailed result, check outpy-spyor any other runtime profiler.Gettingdependenciesimport timeGiven an import, shows the the time spent importing direct dependencies.
The import timedoes includethe time spent on importing other modules.This helps you finding the most time consuming imports in your library/app.Examples:$python-mimportfilerrequests
modules:time(%)---------------------------
requests100%
urllib361%
charset_normalizer11%
http.cookiejar10%
idna2%
certifi2%
http.cookies1%
zipfile1%Getting the time in milliseconds:$python-mimportfiler--unit=msrequests
modules:time(ms)----------------------------
requests48ms
urllib329ms
charset_normalizer5ms
http.cookiejar4ms
idna1ms
certifi1msGettingall_modulesimport timeGiven an import, shows the the time spent loading all its dependencies (including transitive).
The import timedoes not includethe time spent on importing other modules.This helps you finding the most time consuming modules across your chain of dependencies.Examples:$python-mimportfiler--mode="all_modules"requests
modules:time(%)submodules
------------------------------------------------------------
urllib317%urllib3.util.url,urllib3.packages.six,urllib3.exceptions,urllib3.poolmanager,...
email7%email._policybase,email.message,email.header,email.feedparser,...
charset_normalizer6%charset_normalizer.constant,charset_normalizer.models,charset_normalizer.cd,...
requests6%requests.utils,requests.models,requests.exceptions,requests.packages,...
http6%http.cookiejar,http.client,http.cookies
urllib4%urllib.request,urllib.parse,urllib.error,urllib.response
typing3%
ssl2%
importlib2%importlib.resources._adapters,importlib.resources.abc,importlib.resources._common,...
re2%re._parser,re._compiler,re._constants,re._casefixGetting the time in milliseconds:$python-mimportfiler--mode="all_modules"--unit=msrequests
modules:time(ms)submodules
------------------------------------------------------------
urllib318msurllib3.util.url,urllib3.packages.six,urllib3.exceptions,urllib3.connectionpool,...
charset_normalizer8mscharset_normalizer.md__mypyc,charset_normalizer.constant,charset_normalizer.models,...
requests7msrequests.utils,requests.exceptions,requests.models,requests.packages,...
email3msemail._policybase,email.header,email.feedparser,email.utils,...
http3mshttp.cookiejar,http.cookies,http.client
idna2msidna.core,idna.idnadata,idna.package_data,idna.intranges
urllib1msurllib.request,urllib.parse,urllib.error,urllib.response
importlib1msimportlib.resources._adapters,importlib.resources.abc,importlib.resources._common,...
typing1ms
ssl1ms
re1msre._parser,re._compiler,re._constants,re._casefix
Package: importformatter
Groups, lexicographically sorts and formats import statement into the three
groups as defined by PEP8 (standard library, third-party packages, current
package/application.)Imports from the same package are collapsed into a single statement, and
multiple identifiers from the same packages are grouped using parentheses and
separated by a newline.UsageUsage: format-imports.py [options]

Groups, sorts, and formats import statements.

Options:
-h, --help            show this help message and exit
-a APPLICATION, --application=APPLICATION
-s STDLIB_FILES, --stdlib-file=STDLIB_FILES
                        File(s) containing additional module names to add to
                        the standard library set.The script accepts input viastdin, and outputs the formatted code viastdout.ExampleFor the givenbad.py:importsysimportfooimportbarasotherfrombazimport(package,package3,)frommoduleimportpackage3aspackage4frombazimportpackage2,package1importapplicationfromapplication.utilsimportmemoizefromapplication.modelsimportUserfromapplication.modelsimportPlaceimportosThe output offormat-imports.py-aapplication < bad.pywill be:importosimportsysimportbarasotherimportfoofrombazimport(package,package1,package2,package3,)frommoduleimportpackage3aspackage4importapplicationfromapplication.modelsimport(Place,User,)fromapplication.utilsimportmemoizeUsage with VimSelect a chunk of text in visual mode, then invoke theformat-imports.pyscript against the chunk with::'<,'>!format-imports.py -a <application>
Package: import-future-annotations
import-future-annotationsTool that checks presence of importfrom __future__ import annotationsin python files and adds it if it's missing.Installationpip install import-future-annotationsUsageimport-future-annotationstakes filenames as positional arguments.Additional options:--check-only: Don't modify files, only check. If script is applicable to any given file, the exit status code will be 1.--allow-empty: Add import to empty python files aswell.As a pre-commit hookSeepre-commitfor instructionsSample.pre-commit-config.yaml:-repo:https://github.com/mbroton/import-future-annotationsrev:v0.1.0hooks:-id:import-future-annotationsHow does it work?file.pybefore:importosimportsys...Run pre-commit hook or execute command:>import-future-annotationsfile.py
Addingannotationsimporttofile.pyfile.pyafter:+ from __future__ import annotationsimport os
import sysIt will be added always on top of the file.
It won't add any blank lines, so I suggest to use/place it beforereorder_python_importshook.
Package: import-git-files
import-git-filesRead The Docsimport-git-filesenables defining file imports from 1 or more git repositories (public or private) to local destinations.This supports use of polyrepos that may be related. Each repository may follow release definitions that the repository should only contain
what is released together, yet it may be a sub-project or related project to other repositories. This import tool allows defining imports
into other projects which can include commit shas, tags, and releases.InstallationRequires Python 3.6+ and either OS X or Linux.
It is not tested or supported on Windows. This is only developed and tested
against GitHub repositories, but may work elsewhere.pip install import-git-filesUsageusage: import-git-files [-h] [--version] [-v] [-t TEMPORARY_DIRECTORY_PARENT]
                        [--ssh-key SSH_KEY]
                        input

Import files from other repositories. Define the imports in a JSON file and
pass as input argument. If the repositories are private and require
authentication but you do not have cached credentials and are using it in a
non-interactive way, you can either define a Personal Access Token in your
Environment under variable GITHUB_TOKEN or you can specify a path to an SSH
Deploy Key.

positional arguments:
  input                 The input json with a hash of repo URLs and their
                        value being hash of source path and destination path.
                        Source path should be relative to root of repository
                        and the destination path can be absolute or it can be
                        relative to the PWD.

optional arguments:
  -h, --help            show this help message and exit
  --version             show program's version number and exit
  -v, --verbose         Set logging to verbose
  -t TEMPORARY_DIRECTORY_PARENT, --temporary-directory-parent TEMPORARY_DIRECTORY_PARENT
                        Optionally set the parent directory for temporary
                        directories or else will use system tmp default.
  --ssh-key SSH_KEY     Path to an SSH Key with access to the repository. This
                        file needs 600 permissions. This cannot be defined in
                        combination with GITHUB_TOKEN environment variable.note: When needing to setup non-interactive authentication methods,
SSH deploy key is preferred over Personal Access Token. If using a PAT, avoid
setting verbose logging as it may expose the token.You can also useimport_git_filesmodule in your project and the included
context manager,GitExtractedFiles. See thedocsfor more information.
Package: import-graph-python
import-graph-pythonMaps relative imports in your Python project.Local Development / TestingCreate and activate a virtual environmentRunpip install -r requirements-dev.txtto do an editable installRunpytestto run testsType CheckingRunmypy .Create and upload a package to PyPIMake sure to bump the version insetup.cfg.Then run the following commands:rm-rfbuilddist
pythonsetup.pysdistbdist_wheelThen upload it to PyPI usingtwine:twineuploaddist/*
Package: importhelper
importhelperImportsosthreadingtracebacksubprocesssysgcRequirementspipInstallationHopefully...pip install importhelper... should work.UseHas a class namedMod(modules,src,package)which can almost directly translate to a pip package and the imports/installs to be made from said pip package. Custom urls for packages are not supported. (Only uses official packages from PyPI)You can import the class by:from importify import ModAModobject's uses by example:flaskMod = Mod(modules="jsonify,Flask as flsk",src="flask",package="Flask")
# If 'package' is not provided, it will take 'src's value
# 'src' and 'package' can only be strings
# 'modules' can either be a string with format "<Module> as <Name>,<Module2> as <Name2>,.."
# or can be a list like ["<Module> as <Name>","<Module2> as <Name2>"]
# or can be a dict like {"<Module>":"<Name>","<Module1>":"<Name2>"}
## Yes... I know Name:Module for dict makes more sense but izz too much effort to do that (Only 2 lines but still) =-=

# Imports "Flask" from the "flask" module as "flsk" (Literal execution is "from flask import Flask as flsk" and also "jsonify" from the "flask" module (Literal execution is "from flask import jsonify") if it is installed*
flaskMod.attemptImport()

# Installs package "Flask" if it is not installed*
flaskMod.install()

# Uninstalls package "Flask" if it is installed*
flaskMod.uninstall()

# Returns boolean value 'True' if the package is installed*
flaskMod.isInstalled()

requestsModTheModclass has a static variable called PIP_FREEZE(Basically saves the information of allcurrentlyinstalled packages). Thus, calling multiple Mod.install() or Mod.uninstall()'s is not recommended because PIP_FREEZE might be corrupted/have bad data.
PIP_FREEZE is only refreshed when loading of the importify module and on install/uninstall of aModpackage.Other featuresYou can manually refresh PIP_FREEZE byMod.refreshPipFreezeInfo()Mod.getPipFreeze()returns a list ofModVersions that you can use to determine which packages are installed of which version. You can compare saidModVersionobjects with each other. Just check the methods honestly.Disabling print messages for import, install, uninstallTheModclass has around 9 static "silencing" boolean variables which, upon enabling, will stop printing their respective msgz.
Eg:Mod.SILENCE_UNINSTALL_ERRORS=True# Silence error messages when usingMod.uninstall()They are allFalseby default (No silencing)PurposeThis project was built solely for the purpose of providing a way to automate package installations and imports when sending over .py files that require certain imports but they aren't installed i.e.,import requeststhrows an error because you don't have it installed.
It also helps when you have incompatibilities and need ways to workaround by uninstalling, installing and uninstalling certain packages in certain orders.
(Bad and incompatible package creators.... You are the reason for thiseyes intensely)
Package: importhook
Importhookimporthookis a Python package that lets you configure functions to call whenever a specific module is imported.InstallationpipinstallimporthookUsageConfigure a hook to be called whensocketmodule is imported.importimporthook# Setup hook to be called any time the `socket` module is imported and loaded into module cache@importhook.on_import('socket')defon_socket_import(socket):print('"socket" module has been imported')# Import moduleimportsocketYou can also useimporthookto intercept and modify a module on import by returning a Python module from your hook function.importimporthook# Setup hook to be called any time the `socket` module is imported and loaded into module cache@importhook.on_import('socket')defon_socket_import(socket):new_socket=importhook.copy_module(socket)setattr(new_socket,'gethostname',lambda:'patched-hostname')returnnew_socket# Import moduleimportsocket# Prints: 'patched-hostname'print(socket.gethostname())importhookalso comes with helpers to reload modules that have already been imported.importsocketimportimporthook# Setup hook to be called any time the `socket` module is imported and loaded into module cache# DEV: `on_socket_import` will be called immediately because the `socket` module is already loaded@importhook.on_import('socket')defon_socket_import(socket):print('"socket" module has been imported')# Reload the socket module# DEV: Reassign to `socket` in case one of our hooks modifies the modulesocket=importhook.reload_module(socket)Design decisionsOverwriting sys.meta_pathIf a Python developer wants to modify the import behavior they can do so by adding a newimportlib.abc.Finderclass intosys.meta_path.importsys# Add our custom `importlib.abc.Finder` to `sys.meta_path`sys.meta_path.append(MyCustomFinder)One of the major design decisions we have taken withimporthookis to wrap/overwritesys.meta_path.
What it means is thatimporthookwill continue to work as expected regardless of any other modifications ofsys.meta_path.There is however one caveat, if you were to dosys.meta_path = [MyCustomFinder] + sys.meta_paththensys.meta_pathwill get
converted back into alist. Existing modifications to the finders insys.meta_pathwill still work as expected, but any
new finders added will not get hooked.
Package: importio2
IMPORT.IO API FOR PYTHONPython bindings and other tools for interacting with the Import.io
service.© 2016-2017 Import.ioPrerequistesPython 3.4 or laterInstallation$ pip install importio2ContributingDevelopment Environment SetupInstall virtualenv if not installed on your systemConfigure a python virtual environmentInstall required python packagesInstall virtualenvFor installation of virtualenv on your system visit here if not already
presentConfiguring a python virtual environmentvirtualenv is used to create an isolated Python environments. To create
such environment run the following:$ virtualenv pythonTo activate the environment run the following:$ source python/bin/activateTo deactivate the environment run the following:$ deactivateInstall Python packages$ pip install -r requirements.txt
Package: import-ipynb
MotivationSuppose you want to import the contents of A.ipynb into B.ipynb.Installationpipinstallimport-ipynbHow to usePlace both ipynb files in the same directory. Then, in the B.ipynb:importimport_ipynbimportACongratulations! You can now run any functions defined in A.ipynb from
B.ipynb!How it worksThe code within import_ipynb.py defines a “notebook loader” that allows
you to ‘import’ other ipynb files into your current ipynb file. This
entails:load the notebook document into memorycreate an empty Moduleexecute every cell in the Module namespaceNote that since every cell in the A.ipynb is executed when you import
the the file, A.ipynb should only contain classes and function
definitions (otherwise you’ll end up loading all variables and data into
memory).CreditsThe code within imoprt_ipynb.py comes fromhttp://jupyter-notebook.readthedocs.io/en/latest/examples/Notebook/Importing%20Notebooks.html.Riley F. Edmunds (@rileyedmunds) wrote instructions on how to use it
and Lev Maximov (@axil) packaged it.
Package: importit
importitImport python code from anywhere.importitis a python code import helper. Using it, you can dynamically import python code from different sources (like gists, python files on the internet, local python files). You don't need to copy python code snippets from project to project.Some of use cases can be:Reusing python code snippets in multiple places and projectsDynamically reloading python code on live environmentsYou tell me, what will you use it for?From where do you want to import?Github GistFind the gist id from the gist url:https://gist.github.com/<username>/<gist id>Usingthis gistas an exmaple:fromimportitimportimport_gistimported_gist=import_gist("imported_gist","51dcf067f4e445c3f837d26efd2c138e")imported_gist.first_file.some_function()imported_gist.second_file.some_other_function()Note:The gist will be imported in the form of module, with each python file in the gist as a submodule.Remote FileUse any valid python file url (for example,http://bit.ly/aPythonFile)fromimportitimportimport_remote_fileimported_file=import_remote_file("imported_file","http://bit.ly/aPythonFile")imported_file.some_function()Local Filefromimportitimportimport_remote_fileimported_file=import_remote_file("imported_file","/home/divykj/aPythonFile.py")imported_file.some_function()Code Snippetfromimportitimportimport_codepython_code="""def some_function():# do some crazy thingspass"""imported_code=import_code("imported_code",python_code)imported_code.some_function()Planning to addGithub,Gitlab,Bitbucket(and other git repository services) and maybePyPIsupport soon.How to install?❯pipinstallimportitWant to contribute?To get more information on contributing, go to theCONTRIBUTING.md.Also read theCODE_OF_CONDUCT.md.
Package: import-java
import-javaImport your Java packages seamlessly into CPython.Quick StartWe'll create a temporary file in Java and then read it in Python to illustrate the usage:>>>importjava>>>withjava:...fromjava.langimportString...fromjava.nio.fileimportFiles...>>>temp_path=Files.createTempFile('sample','.tmp')>>>sample_text=String('Greetings from Java')>>>Files.write(temp_path,sample_text.getBytes())<java.nio.file.Pathat0x...jclass=java/nio/file/Pathjself=...>>>>withopen(temp_path.toString())asf:...print(repr(f.read()))...'Greetings from Java'You can also use_as a short alias forjava.lang:>>>withjava:...from_importSystem...>>>System.getProperties().get('java.specification.version')'1.8'Wildcard imports (such asfrom java.util import *) are not supported yet.DependenciesEitherPyJNIusorJavaBridge. PyJNIus is preferred, asJavaBridge cannot disambiguate overloaded methods with the same number of parameters.Installation$ pip install import-javaLicenseMIT.See alsopythonnet- Import .NET CLR moduleshack-py-import- Import your C libraries
Package: importjson
importjson : Import json data into a python applicationIt is sometimes useful to be able to use json data to initialise classes and other data structures, giving your application a portable and human readable configuration capability. To do this you will probably write some level of functionality around the json standard library, and use the resulting data loaded from the json file, to populate classes and instances implemented in your application. This separates your data and functionality, which can often present challenges later down the line as you need to keep the data and functionality in step. It would be better in many cases to be able to combine the data and functionality in a single place, and with the importjson library you can do that.The library allows you to import a json file direct into your python application, and automatically build a real python module,
complete with classes, class attributes, and instance data attributes (implemented with set and get descriptors).Your code can use these classes, attributes and methods just as if you have written the code yourself.The importjson library also allows you to set constraints on your instance attributes, checking for the data type and simple range checks on the values your attempt to set when you create instances of the classes. You can also determine whether attributes are read only, or whether they will be allowed to be set to None (or not).See the full documentation for examples of how to use the library and how to format the json file.Full DocumentationOn PyPi (Python Package Index)Source code on GitHubBugsEvery care is taken to try to ensure that this code comes to you bug free.
If you do find an error - please report the problem on :GitHubor
by email to :Tony Flury
Package: importkit
Importkit is a Python library for making anything importable as a Python module.Importkit uses and extendsimportlib, introduced in Python 3.1, to provide
a straightforward framework for creating importers, allowing non-Python code or
data to beimport-ed seamlessly.Importkit includes an implementation of a generic, schema-based YAML DSL that
makes it easy to represent complex objects in a robust declarative format.Importkit also implements module tagging and automatic translation, which makes
it possible to use general module dependency graph to perform cross-platform
builds from a single source.
Package: importlab
importlabImportlab is a library for Python that automatically infers dependencies
and calculates a dependency graph. It can perform dependency ordering of
a set of files, including cycle detection.Importlab’s main use case is to work with static analysis tools that
process one file at a time, ensuring that a file’s dependencies are
analysed before it is.(This is not an official Google product.)LicenseApache 2.0InstallationImportlab can be installed from pippip install importlabTo check out and install the latest source codegit clone https://github.com/google/importlab.git
cd importlab
python setup.py installUsageImportlab is primarily intended to be used as a library. It takes one or
more python files as arguments, and generates an import graph, typically
used to process files in dependency order.It is currently integrated intopytypeCommand-line toolImportlab ships with a small command-line tool, also calledimportlab, which can display some information about a project’s
import graph.usage: importlab [-h] [--tree] [--unresolved] [filename [filename ...]]

positional arguments:
  filename              input file(s)

optional arguments:
  -h, --help            show this help message and exit
  --tree                Display import tree.
  --unresolved          Display unresolved dependencies.RoadmapMakefilegeneration, to take advantage ofmake’s incremental
update and parallel execution featuresIntegration with other static analysis tools
Package: importlib
PurposeThis package contains the code from importlib as found in Python 2.7. It is
provided so that people who wish to useimportlib.import_module()with a
version of Python prior to 2.7 or in 3.0 have the function readily available.
The code in no way deviates from what can be found in the Python 2.7 standard
library.For documentation, see theimportlib docsfor Python 2.7.Notice about maintenanceDue to the fact that this project is only applicable to versions of Python that
are nolonger supported,
there will be no further maintenance of this project. Since the code included
in this project is simply copied from Python 2.7 itself, if you need updated
fixes you can copy the files manually on your own.