Saravanan666/pypi-org huggingface dataset:
Package: directory-api-external
directory-api-client-externalExport Directory external API client.Installation$pipinstalldirectory-api-externalThe api client expects the following settings:SettingNotesDIRECTORY_API_CLIENT_EXTERNAL_BASE_URLDIRECTORY_API_CLIENT_EXTERNAL_API_KEYUnique to client. Retrieved during the on-boarding process.DIRECTORY_API_CLIENT_EXTERNAL_SENDER_IDUnique to client. Retrieved during the on-boarding process.DIRECTORY_API_CLIENT_EXTERNAL_DEFAULT_TIMEOUTOnce that is done the API client can be used:fromdirectory_api_external.clientimportapi_clientDevelopment$ git clone https://github.com/uktrade/directory-api-client-external
$ cd directory-api-client-externalPublish to PyPIThe package should be published to PyPI on merge to master. If you need to do it locally then get the credentials from rattic and add the environment variables to your host machine:SettingDIRECTORY_PYPI_USERNAMEDIRECTORY_PYPI_PASSWORDThen run the following command:make publish
Package: directory-ch-client
directory-companies-house-search-clientExport Directory internal Companies House search client.RequirementsInstallationpipinstalldirectory-ch-clientUsagefromdirectory_ch_client.clientimportclientresponse=client.company.search_companies(query='Foo Bar')Development$ git clone https://github.com/uktrade/directory-companies-house-search-client
$ cd directory-companies-house-search-client
$ makePublish to PyPIThe package should be published to PyPI on merge to master. If you need to do it locally then get the credentials from rattic and add the environment variables to your host machine:SettingDIT_PYPI_USERNAMEDIT_PYPI_PASSWORDThen run the following command:make publish
Package: directory-client-core
directory-client-coreDirectory Client Core.Common code for the Directory API clients.RequirementsInstallationpipinstalldirectory-client-coreUsagefromdirectory_client_core.baseimportAbstractAPIClientclassMyAPIClient(AbstractAPIClient):version=1# passed as a header in all requestsdefget_something(self):returnself.get(...)defcreate_sometime(self):returnself.post(...)client=MyAPIClient(base_url='https://example.com/',api_key='test',sender_id='test-sender-id',timeout=2,)response=client.get_something()CachingThe decoratordirectory_client_core.helpers.fallbackcan be used to cache the responses from the remote server, allowing the cached content to be later used if the remote server does not return the up to date live content (maybe it times out, maybe the server is down). This decorator also saves etag response headers to later expose them in requests and respect 304 (Not modified) response and serve already cached contents.# settings.py
DIRECTORY_CLIENT_CORE_CACHE_EXPIRE_SECONDS = 60 * 60 * 24 * 30  # 30 days

# client.py

from django.core.cache import caches

from directory_client_core import helpers
from directory_client_core.base import AbstractAPIClient


class APIClient(AbstractAPIClient):
    version = 1

    @helpers.fallback(cache=caches['fallback'])
    def get(self, *args, **kwargs):
        return super().get(*args, **kwargs)

    def retrieve(self):
        return self.get(url='/some/path/')Thefallbackcreates log entries when cache events occur. To reduce noiseDIRECTORY_CLIENT_CORE_CACHE_LOG_THROTTLING_SECONDScan be set in settings. This will result in a log event being created only once every period of time. By default this means seeing "cache hit for url x" (for a given url) is shown once every 24 hours.Development$ git clone https://github.com/uktrade/directory-client-core
$ cd directory-client-core
$ make test_requirementsPublish to PyPIThe package should be published to PyPI on merge to master. If you need to do it locally then get the credentials from rattic and add the environment variables to your host machine:SettingDIRECTORY_PYPI_USERNAMEDIRECTORY_PYPI_PASSWORDThen run the following command:make publish
Package: directory-cms-client
directory-cms-clientDirectory CMS client.Client for the Directory Content Management read-only API.Installation$ pip install directory-cms-clientThe api client expects the following settings:SettingNotesDIRECTORY_CMS_API_CLIENT_BASE_URLDIRECTORY_CMS_API_CLIENT_API_KEYUnique to client. Retrieved during the on-boarding process.DIRECTORY_CMS_API_CLIENT_SENDER_IDUnique to client. Retrieved during the on-boarding process.DIRECTORY_CMS_API_CLIENT_DEFAULT_TIMEOUTDIRECTORY_CMS_API_CLIENT_SERVICE_NAMEUnique to client, can be hardcoded.The followingdirectory client core settingsalso apply to directory cms client:SettingNotesDIRECTORY_CLIENT_CORE_CACHE_EXPIRE_SECONDSDuration to store the retrieved content in the cache.DIRECTORY_CLIENT_CORE_CACHE_LOG_THROTTLING_SECONDSDuration to throttle log events for a given url for.And also specify a cache with namecms_fallback:CACHES = {
    'cms_fallback': ...
}Once that is done the API client can be used:fromdirectory_api_client.clientimportcms_api_clientDevelopment$gitclonehttps://github.com/uktrade/directory-cms-client
$cddirectory-cms-client
$[createvirtualenvironmentandactivate]$maketest_requirementsPublish to PyPIThe package should be published to PyPI on merge to master. If you need to do it locally then get the credentials from rattic and add the environment variables to your host machine:SettingDIRECTORY_PYPI_USERNAMEDIRECTORY_PYPI_PASSWORDThen run the following command:$ make publish
Package: directory-constants
directory-constantsInstallationpipinstalldirectory-constantsEnvironment variablesTo change the default value of urls add the following to your settings.py:Setting namedefault valueDIRECTORY_CONSTANTS_URL_GREAT_DOMESTIChttps://www.great.gov.ukDIRECTORY_CONSTANTS_URL_SINGLE_SIGN_ONhttps://www.great.gov.uk/sso/DIRECTORY_CONSTANTS_URL_EXPORT_OPPORTUNITIEShttps://www.great.gov.uk/export-opportunities/DIRECTORY_CONSTANTS_URL_FIND_A_BUYERhttps://www.great.gov.uk/find-a-buyer/DIRECTORY_CONSTANTS_URL_SELLING_ONLINE_OVERSEAShttps://www.great.gov.uk/selling-online-overseas/DIRECTORY_CONSTANTS_URL_FIND_A_SUPPLIERhttps://www.great.gov.uk/trade/DIRECTORY_CONSTANTS_URL_INVESThttps://invest.great.gov.ukDIRECTORY_CONSTANTS_URL_EVENTShttps://www.events.trade.gov.ukDevelopment$ git clone https://github.com/uktrade/directory-constants
$ cd directory-constants
[Create and activate your virtual environment]
$ make test_requirementsTesting$ make testPublish to PyPIThe package should be published to PyPI on merge to master. If you need to do it locally then get the credentials from rattic and add the environment variables to your host machine:SettingDIRECTORY_PYPI_USERNAMEDIRECTORY_PYPI_PASSWORDThen run the following command:make publish
Package: directory-downloader
Directory DownloaderDirectory Downloader
is a Python library for downloading files from websites using thedirectory listingfunction used mostly in apache/nginx and ftp an example can be seenhereDependenciesBefore installation, make sure you have the required dependencies of asyncio, aiohttp, bs4 and colorama.InstallationUse the package managerpipto install directory_downloader.pipinstalldirectory-downloaderUsageimportasynciofromdirectory_downloaderimportDDownloaderasyncdefmain():url="https://example.com/directory/"downloader=DDownloader()awaitdownloader.crawl(url)# fetch all the links from /directory/awaitdownloader.download_files()# download all files to current directoryif__name__=='__main__':asyncio.run(main())Advanced Usageto disable coloring:downloader=DDownloader(coloring=False)to disable verbose mode:downloader=DDownloader(verbose=False)to change the directory simply add:downloader.download_files(full_directory=r"C:\Users\User\Desktop")to make downloads faster you can increase the number of workers (by default 5):downloader.download_files(workers=5)note : increasing the number of workers too much can lead to unstable behavior use at your own riskto fetch file links that have extension of pdf only you can use:awaitdownloader.crawl(extensions=[".pdf"])you can also use regex like the following:awaitdownloader.crawl(filter=r"test\d\d\d\.apk")to download an existing list of urls you can do as follow:urls=set(["www.example/example/file1.pdf","www.example/example/file2.pdf",...])awaitdownloader.download_files(urls=urls)also you can use filter on downloadable files:awaitdownloader.download_files(urls=urls,filter=r"test\d\d\d\.apk")ContributingPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Package: directoryhash
DirectoryHash is a library for Python. It gives an opportunity to get a hash of the destination folder. You can choose file types, which will participate in the calculations.Github repoInstallationInstall using pip:pip install directoryhash…or clone the project from github:https://github.com/san4ezy/directoryhash.gitHow to use?Getting hash for whole directory:from directoryhash import md5, sha1

md5_hash = md5("path_to_directory")
sha1_hash = sha1("path_to_directory")Getting hash for directory including html and css only:from directoryhash import md5, sha1

filetypes = ('.html', '.css',)

md5_hash = md5("path_to_directory", filetypes)
sha1_hash = sha1("path_to_directory", filetypes)Catching exceptions:from directoryhash import md5, HashedDirectoryDoesNotExist

directory_path = "path_to_destination_folder"
try:
    md5(directory_path)
except HashedDirectoryDoesNotExist as e:
    print(e)
Package: directory-healthcheck
directory-healthcheckWrapper arounddjango-health-checkto streamline health checks indirectory apps.Installationpipinstalldirectory-healthcheckUsageUpdate yoursettings.py:importdirectory_healthcheck.backendsINSTALLED_APPS=[...'directory_healthcheck',...]DIRECTORY_HEALTHCHECK_TOKEN='some-secret-token'DIRECTORY_HEALTHCHECK_BACKENDS[directory_healthcheck.backends.APIBackend,directory_healthcheck.backends.SingleSignOnBackend,directory_healthcheck.backends.FormsAPIBackend,]Update yoururls.py:url(
        r'^healthcheck/$',
        directory_healthcheck.views.HealthcheckView.as_view(),
        name='healthcheck'
    ),Development$ git clone https://github.com/uktrade/directory-healthcheck
$ cd directory-healthcheck
$ makePublish to PyPIThe package should be published to PyPI on merge to master. If you need to do it locally then get the credentials from rattic and add the environment variables to your host machine:SettingDIRECTORY_PYPI_USERNAMEDIRECTORY_PYPI_PASSWORDThen run the following command:make publish
Package: directory-observer
Directory Observer(Windows only) The package implements an observable to monitor directory changes, and to notify observers when a change is detected.
The observable is running in a separate daemon thread, and is being locked while there are no changes (non-busy-waiting).Installationpython3 -m pip install directory-observerUsage Examplesfromdirectory_observerimportDirectoryObservabledefupdate(path:str):# Handle change in path# Initialize Observable with update() as observer functionobservable=DirectoryObservable(path,observers=[update])observable.start()# Start observable threadobservable.remove_observer(update)# Remove observerobservable.add_observer(update)# Add new observerobservable.stop()# Stop observable thread# Use "with" statement to call start() and stop()withDirectoryObservable(path,observers=[update])asobservable:# Observe directory in this section
Package: directory-proxy
directory-proxyProxy for rejecting non-whitelisted IP addresses.Proxy sets aHawksignature header that the upstream service can check, rejecting requests that do not have a valid signature.Installationpip install directory-proxyUsageProxy can be ran as a standalone service or as a WSGI worker running alongside the upstream service.WSGI workerThe proxy can be run on the same box as the upstream service. Install proxy on the same box as the upstream service then run the WSGI worker:DJANGO_SETTINGS_MODULE=directory_proxy.conf.settings\gunicorndirectory_proxy.conf.wsgi--bind0.0.0.0:$UPSTREAM_PORTStandalone serviceIf you're unable to run the WSGI worker on the same box as the upstream service then the proxy can be ran as a standlone service.ConfigurationSet the following environment variables to configure the proxy:Environment variableDetailsIP_RESTRICTOR_ALLOWED_ADMIN_IPSAllow IP addresses. Command delimitedIP_RESTRICTOR_ALLOWED_ADMIN_IP_RANGESAllow IP ranges. Command delimitedIP_RESTRICTOR_SKIP_CHECK_ENABLEDSkip IP check. Check cookie insteadIP_RESTRICTOR_SKIP_CHECK_SECRETShared secret for checking cookieUPSTREAM_DOMAINDomain of upstream serviceUPSTREAM_SIGNATURE_SECRETHawk shared secret for upstream requestUPSTREAM_SIGNATURE_SENDER_IDHawk sender ID for upstream requestLocal installation$ git clone https://github.com/uktrade/directory-proxy
$ cd directory-proxyDebuggingSetup debug environment$ make debugRun debug webserver$ make debug_webserverRun debug tests$ make debug_test
Package: directory-schema
directory_schemaUse JSON Schema to validate directory structures:
The specified directory is translated into a JSON structure like the output fromtree -J,
and is validated against a JSON Schema, provided as a dict inside Python,
or as a JSON or YAML file through the CLI.Sample schemas and directories are in thetest fixtures.Instructions for contributors arehere.CLI$ directory_schema -h
usage: directory_schema [-h] DIRECTORY SCHEMA

positional arguments:
  DIRECTORY   Directory to validate
  SCHEMA      Schema (JSON or YAML) to validate against

optional arguments:
  -h, --help  show this help message and exitPython>>> from directory_schema import directory_schema
>>> directory_schema.validate_dir(
...   'tests/fixtures/just-a-placeholder',
...   {'items':
...     {'properties':
...       {'name':
...         {'pattern': 'not-placeholder'}}}}
... )
Traceback (most recent call last):
  ...
    raise DirectoryValidationErrors(errors)
directory_schema.directory_schema.DirectoryValidationErrors: This string:
    placeholder

fails this "pattern" check:

    not-placeholder
    ...Thank youThis package was created with Cookiecutter and thecs01/cookiecutter-pypackageproject template.Cookiecuttercs01/cookiecutter-pypackage
Package: directoryshard
directoryshardShard filenames into subdirectories.A large number of files in a single directory can make operations such as listing or browsing cumbersome.
Splitting files into subdirectories alleviates this.APITwo methods are provided:def shardprefix(filename: str) -> str:
"""Return a 2 character alphanumeric string by deterministically hashing filename"""

def sharded(filepath: Path) -> Path:
 """Return path sharded into subdirectory"""ClassShardedDirectoryprovides getting file paths from a directory:sharded_tmp = ShardedDirectory('/tmp)
print(sharded_tmp.filepath('python'))return/tmp/ep.python.
Package: directory-splitter
Directory SplitterDescriptionThis script takes a list of URLs from a file, extracts unique endpoints, and stores them in an output file.UsagePrerequisitesPython 3.x installedRunning the ScriptOpen a terminal.Navigate to the directory containing the script.Run the following command:pythonscript_name.py-listinput_file.txt-outputoutput_file.txtReplacescript_name.py,input_file.txt, andoutput_file.txtwith the actual names.Command Line Arguments-listor--list: Input file with recon data.-outputor--output: Output file to store split endpoints.Python Module InstallationPyPi Module Linkpip install directory-splitter
Package: directory-sso-api-client
directory-sso-api-clientDirectory SSO API clientInstallation$pipinstalldirectory-sso-api-clientThe api client expects the following settings:SettingNotesDIRECTORY_SSO_API_CLIENT_BASE_URLDIRECTORY_SSO_API_CLIENT_API_KEYUnique to client. Retrieved during the on-boarding process.DIRECTORY_SSO_API_CLIENT_SENDER_IDUnique to client. Retrieved during the on-boarding process.DIRECTORY_SSO_API_CLIENT_DEFAULT_TIMEOUTOnce that is done the API client can be used:fromdirectory_sso_api_client.clientimportsso_api_clientAuthentication backendAdd the following to your settingsAUTHENTICATION_BACKENDS = ['directory_sso_api_client.backends.SSOUserBackend']

AUTH_USER_MODEL='directory_sso_api_client.SSOUser',

MIDDLEWARE_CLASSES = [
    ...
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    ...That will result in the user being authenticate via their sso session cookie and then attached torequest.user.Development$gitclonehttps://github.com/uktrade/directory-sso-api-client
$cddirectory-sso-api-client
$[createvirtualenvironmentandactivate]$pipinstall-rrequirements_test.txtPublish to PyPIThe package should be published to PyPI on merge to master. If you need to do it locally then get the credentials from rattic and add the environment variables to your host machine:SettingDIRECTORY_PYPI_USERNAMEDIRECTORY_PYPI_PASSWORDThen run the following command:makepublish
Package: directory-structure
directory-structurePrint a directory tree structure in your Python code.DownloadYou can simply:pipinstalldirectory-structureOr you can also:Clone the repository to your local machine.Enter the directory.Download necessary modules/libraries.gitclonehttps://github.com/gabrielstork/directory-structure.gitcddirectory-structure
pipinstall-rrequirements.txtExamplesfromdirectory_structureimportTreeUsing absolute path as an argument.path=Tree('C:/Users/User/Desktop/directory-structure',absolute=True)print(path)📂 C:
|_📂 Users
  |_📂 User
    |_📂 Desktop
      |_📂 directory-structure
        |_📁 .git
        |_📁 directory_structure
        |_📄 .gitignore
        |_📄 LICENSE
        |_📄 pyproject.toml
        |_📄 README.md
        |_📄 requirements.txt
        |_📄 setup.pypath=Tree('C:/Users/User/Desktop/directory-structure',absolute=False)print(path)📂 directory-structure
|_📁 .git
|_📁 directory_structure
|_📄 .gitignore
|_📄 LICENSE
|_📄 pyproject.toml
|_📄 README.md
|_📄 requirements.txt
|_📄 setup.pyAccessing a folder in current working directory.path=Tree('./directory_structure',absolute=True)print(path)📂 C:
|_📂 Users
  |_📂 User
    |_📂 Desktop
      |_📂 directory-structure
        |_📂 directory_structure
          |_📄 tree.py
          |_📄 __init__.pypath=Tree('./directory_structure',absolute=False)print(path)📂 directory_structure
|_📄 tree.py
|_📄 __init__.pyGetting all from the directory where your current working directory is.path=Tree('../',absolute=True)print(path)📂 C:
|_📂 Users
  |_📂 User
    |_📂 Desktop
      |_📁 directory-structure
      |_📄 Discord.lnk
      |_📄 Spotify.lnk
      |_📄 Steam.lnk
      |_📄 Telegram.lnk
      |_📄 Visual Studio Code.lnk
      |_📄 WhatsApp.lnkpath=Tree('../',absolute=False)print(path)📂 Desktop
|_📁 directory-structure
|_📄 Discord.lnk
|_📄 Spotify.lnk
|_📄 Steam.lnk
|_📄 Telegram.lnk
|_📄 Visual Studio Code.lnk
|_📄 WhatsApp.lnk
Package: directory-to-sql
Get a SQLite database of a directory tree.The data retrived includes:File sizes and modification date.Folder sizes and file counts.Recursive (including sub-folders) folder sizes and file counts.To create the database and execute some example queries
listing largest files and folders:from directory_to_sql import get_db, top_10
conn = get_db('\\', 'db.db')
top_10(conn)
Package: directory-tree
Directory Tree PackageAboutWant to Display your Project/Current Working Directory as a Neat Tree? No Worries!Directory Treeis a simple python utility package that displays out the Tree Structure of a User Defined Directory.Currently Available for All Platforms.InstallationRun the Following Command on your Terminal to Installdirectory_tree:1 .  Installing the Package usingpip:pipinstalldirectory_treeORpip3installdirectory_tree2 . Cloning the Repository:gitclonehttps://github.com/rahulbordoloi/Directory-Tree/cdDirectory-Tree
pipinstall-e.UsageFunction Signaturedisplay_tree(dir_path:str='',string_rep:bool=False,header:bool=False,max_depth:float=float("inf"),show_hidden:bool=False,ignore_list:list=None)Arguments DescriptionParametersDescriptiondir_pathRoot Path of Operation. By Default, Refers to the Current Working Directory.string_repBoolean Flag for Direct Console Output or a String Return of the Same. By Default, It Gives out Console Output.headerBoolean Flag for Displaying [OS & Directory Path] Info in the Console. Not Applicable ifstring_rep=True.max_depthMax Depth of the Directory Tree. By Default, It goes upto the Deepest Directory/File.show_hiddenBoolean Flag for Returning/Displaying Hidden Files/Directories if Value Set toTrue.ignore_listList of File and Directory Names or Patterns to Ignore.Run this Script in Order to Print out the Tree Structure of a User-Defined DirectoryDirectoryPath!# Importing Librariesfromdirectory_treeimportdisplay_tree# Main Methodif__name__=='__main__':display_tree(DirectoryPath)Here by default, theDirectoryPathis the current working directory (CWD) unless specified by the user.Output ExamplesSample Directory Tree -NOTE - Here,letseee.txt(File) andDirectory 4/(Directory) areHIDDENin Nature.ForCurrent Working Directorywith Argument [Header Info =False]fromdirectory_treeimportdisplay_treedisplay_tree(header=True)ForUser Specified Directorywith Arguments [String Representation =True, Show Hidden Entities =True]fromdirectory_treeimportdisplay_treecustomPath='D:\Work\Python Packages Maintainence\Directory-Tree\Test\Main Directory'stringRepresentation=display_tree(customPath,string_rep=True,show_hidden=True)print(stringRepresentation)ForCurrent Working Directorywith Argument [Max Depth =2]fromdirectory_treeimportdisplay_treedisplay_tree(max_depth=2)DevelopingDirectory TreeTo installdirectory_tree, along with the tools you need to develop and run tests, and execute the following in your virtualenv:$pipinstall-e.[dev]Security & Probable BugsDirectory Treeuses recursion. It will raise aRecursionErroron really deep directory trees.As the tree is lazily evaluated, it should behave well on really wide directory trees. Immediate children of a given directory are not lazily evaluated, though. It would be prompted to the last.If you're a Windows user, it is always advised to use\\instead of\in the address as using\might catchup escape sequences and corrupt the address string.Contact AuthorName :Rahul BordoloiWebsite :https://rahulbordoloi.meEmail :rahulbordoloi24@gmail.comMade with♥in Python!
Package: directory-tree-generator
directory-tree-generatorRequirementspython >= 3.0Installationpip install directory-tree-generatorUsagePass the directory path to the generate methodfromDirectoryTreeimportTreeGeneratorTree=TreeGenerator()Tree.generate('C:/users/Ajay/Desktop/Junk')Output+ Junk/
   + Stylesheets/
       • country.css
   + Java Files/
       • mm.java
   + Media/
      + Images/
          • globe.png
          • 1598791605362.jpg
      + GIFs/
          • connection_11598806195526.gif
      + Audios/
          • Sound.mp3
   + Database Files/
       • db.sqlite3
   + PDFs/
       • Pdf.pdf
   + Javascript Files/
       • app.js
   + Python Files/
       • Notepad.py
   + Text Files/
       • requirements.txt
   + HTML Files/
       • share.html
   + Json Files/
       • package-lock.json
   + Documents/
       • DBMS_ALL Programs.docx
   + Readme Files/
       • README.md
Package: directory-validators
directory-validatorsDirectory of UK Exporters validatorsRequirementsInstallationpipinstalldirectory_validatorsUsagefromdirectory_validatorsimportenrolmentenrolment.validate_company_number('12345678')enrolment.validate_email('test@example.com')Development$ git clone https://github.com/uktrade/directory-validators
$ cd directory-validators
$ makeTesting$ py.test .Publish to PyPIThe package should be published to PyPI on merge to master. If you need to do it locally then get the credentials from rattic and add the environment variables to your host machine:SettingDIRECTORY_PYPI_USERNAMEDIRECTORY_PYPI_PASSWORDThen run the following command:make publish