Saravanan666/pypi-org huggingface dataset:
Package: ruamel.std.encryptedzip
ruamel.std.encryptedzip is a modified library that adds support for encrypted zip archives to ruamel.std.zipfile; linked below.https://pypi.org/project/ruamel.std.zipfile/It is super simple, it just adds an extra parameter to the API:def delete_from_zip_file(self, pattern=None, file_names=None, password=None): #Take extra parameter for password.
        """
        zip_file can be a string or a zipfile.ZipFile object, the latter will be closed
        any name in file_names is deleted, all file_names provided have to be in the ZIP
        archive or else an IOError is raised
        """
        if pattern and isinstance(pattern, string_type):
            import re
            pattern = re.compile(pattern)
        if file_names:
            if not isinstance(file_names, list):
                file_names = [str(file_names)]
            else:
                file_names = [str(f) for f in file_names]
        else:
            file_names = []
        with zipfile.ZipFile(self._file_name) as zf:
            zf.setpassword(password) #Set the password for the zip file.
            for l in zf.infolist():
                if l.filename in file_names:
                    file_names.remove(l.filename)
                    continue
                if pattern and pattern.match(l.filename):
                    continue
                self.append(l.filename, zf.read(l))
            if file_names:
                raise IOError('[Errno 2] No such file{}: {}'.format(
                    '' if len(file_names) == 1 else 's',
                    ', '.join([repr(f) for f in file_names])))


def delete_from_zip_file(file_name, pattern=None, file_names=None, password=None): #Take extra parameter for password (overloaded function).
    with InMemoryZipFile(file_name) as imz:
        imz.delete_from_zip_file(pattern, file_names, password) #Parse the extra parameter to the class' method.It may look scary, but it is very simple. Instead of calling the original function with just a pattern or file_names array, you add an extra parameter where needed:from ruamelmod import delete_from_zip_file
#Code for zip file stuff goes here
password_zip = b'testing123'
delete_from_zip_file("test.zip", file_names=['test.txt', 'test2.txt'], password=password_zip)If I remember correctly, Python will throw a TypeError if your password is not encoded into UTF-8 bytes. At the moment, there is no support for directly giving the method your zipfile.ZipFile object, but I will hopefully add support for that in the future.All credit for code goes to Anthon at Ruamel, all I did was add in a few words and things here and there to add some extra support.
Package: ruamel.std.typing
package ruamel.std.pathlibis a drop-in
replacement to extend the Python standardtyping`module.adds pip install dependency for 2.7/3.3/3.4adds Text for 3.5.0 and 3.5.1This package alleviates the need to do:import sys
if sys.version_info >= (3, 5, 2):
    from typing import Dict, List, Any, Union, Text   # NOQAinstead you can just do:from ruamel.std.typing import Dict, List, Any, Union, Text
Package: ruamel.std.warning
extend warnings.warn with callee parameterWhen you have some library, with some deprecated functionX, you can use thestacklevel=2parameter
onwarnings.warnto show the file-name and line-number of the routine callingXBut if you have some framework that calls the user provided code, either through plug-ins or
by explicit registering, thestackleveldoesn’t help you to complain about return values
that are deprecated.This library extendswarnings.warnwith acalleeparameter. If this is providedstacklevelshould
not be provided and the value forcalleeshould be a method or function for
which the warning is raised.The warning will usually be aPendingDeprecationWarning, aDeprecationWarningor a subclass of either.As an example, if you have two filesp0.pyandp2.pyboth with content:class PlugIn:
 def status(self):
     return {'result': 'ok'}And a filep1.py:class PlugIn:def status(self):return [‘ok’] # this plug-in has been updatedAnd these files are in a subfolderplug_inswhere your framework can find them. Then running:import sys
from pathlib import Path
from importlib import import_module
import ruamel.std.warnings
import warnings

class DictReturnPendingDeprecationWarning(PendingDeprecationWarning):
    pass

class Driver:
    def __init__(self):
        self.plug_ins = []

    def load_plug_ins(self):
        sys.path.append('plug_ins')
        for file_name in Path('plug_ins').glob('p*.py'):
            mod = import_module(file_name.stem)
            self.plug_ins.append(mod.PlugIn())

    def check_status(self):
        for p in self.plug_ins:
            retval = p.status()
            if isinstance(retval, dict):
                # assume dict
                warnings.warn(
                   'callable should return list, not dict',
                   DictReturnPendingDeprecationWarning,
                   callee=p.status,
                )
            else:
                pass  # assume list

warnings.simplefilter('once', PendingDeprecationWarning)

def doit():
    driver = Driver()
    driver.load_plug_ins()
    for idx in range(2):
        driver.check_status()
    warnings.warn('almost done', PendingDeprecationWarning)

doit()will result in:/tmp/plug_ins/p0.py:2: DictReturnPendingDeprecationWarning: callable should return list, not dict
  def status(self):
/tmp/plug_ins/p2.py:2: DictReturnPendingDeprecationWarning: callable should return list, not dict
  def status(self):
/tmp/tmp_00.py:40: PendingDeprecationWarning: almost done
  warnings.warn('almost done', PendingDeprecationWarning)
Package: ruamel.std.warnings
extend warnings.warn with callee parameterWhen you have some library, with some deprecated functionX, you can use thestacklevel=2parameter
onwarnings.warnto show the file-name and line-number of the routine callingXBut if you have some framework that calls the user provided code, either through plug-ins or
by explicit registering, thestackleveldoesn’t help you to complain about return values
that are deprecated.This library extendswarnings.warnwith acalleeparameter. If this is providedstacklevelshould
not be provided and the value forcalleeshould be a method or function for
which the warning is raised.The warning will usually be aPendingDeprecationWarning, aDeprecationWarningor a subclass of either.As an example, if you have two filesp0.pyandp2.pyboth with content:class PlugIn:
 def status(self):
     return {'result': 'ok'}And a filep1.py:class PlugIn:
    def status(self):
        return ['ok'] # this plug-in has been updatedAnd these files are in a subfolderplug_inswhere your framework can find them. Then running:import sys
from pathlib import Path
from importlib import import_module
import ruamel.std.warnings
import warnings

class DictReturnPendingDeprecationWarning(PendingDeprecationWarning):
    pass

class Driver:
    def __init__(self):
        self.plug_ins = []

    def load_plug_ins(self):
        sys.path.append('plug_ins')
        for file_name in Path('plug_ins').glob('p*.py'):
            mod = import_module(file_name.stem)
            self.plug_ins.append(mod.PlugIn())

    def check_status(self):
        for p in self.plug_ins:
            retval = p.status()
            if isinstance(retval, dict):
                # assume dict
                warnings.warn(
                   'callable should return list, not dict',
                   DictReturnPendingDeprecationWarning,
                   callee=p.status,
                )
            else:
                pass  # assume list

warnings.simplefilter('once', PendingDeprecationWarning)

def doit():
    driver = Driver()
    driver.load_plug_ins()
    for idx in range(2):
        driver.check_status()
    warnings.warn('almost done', PendingDeprecationWarning)

doit()will result in:/tmp/plug_ins/p0.py:2: DictReturnPendingDeprecationWarning: callable should return list, not dict
  def status(self):
/tmp/plug_ins/p2.py:2: DictReturnPendingDeprecationWarning: callable should return list, not dict
  def status(self):
/tmp/tmp_00.py:40: PendingDeprecationWarning: almost done
  warnings.warn('almost done', PendingDeprecationWarning)
Package: ruamel.std.zipfile
package ruamel.std.zipfileis a drop-in
improvements over the standard zipfile packageYou can just replace:import zipfilewith:import ruamel.std.zipfile as zipfileThe package includes InMemoryZipFile, which allows easy creation of ZIP files in memory,
and allows for streaming or writing out to disc after full creation:with InMemoryZipFile() as imz:
    imz.append("test.txt", "Another test").append("test2.txt", "Still another")
    with open('some_file.zip', 'wb') as fp:
        fp.write(imz.data)which will write a two file ZIP file, the first file of which is namedtest.txtwith contentAnother test. The.datacontent can
also be dynamically returned to a web browser, etc.File deletion from ZIPTaking advantage of the delayed writing ofInMemoryZipFile, the
functiondelete_from_zip_file(file_name, pattern, file_names),
takes astringorpathlib.Pathas file_name.Any files matching the pattern, if provided, are deleted from the
file, as well as are any files matchingfile_names(a list of
string/Path, single non-list instances are allowed).The following deletes any files ending in.pthand the filetmp/README.rstfrom a ZIP filetest.zip:delete_from_zip_file('test.zip', pattern='.*.pth', file_names=['README.rst'])or:delete_from_zip_file('test.zip', pattern='.*.pth', file_names='README.rst')or:delete_from_zip_file('test.zip', pattern=re.compile('.*.pth'), file_names='README.rst')Please note that this a ``re`` pattern not a ``glob`` pattern.You can, but don’t have to provide a pattern compiled withre.compile()The ZIP file is recreated and recompressed, take this into account
when deleting files (restrict the size of files you handle, combine
patterns instead of doing multiple calls).
Package: ruamel.venvgtk
This package is intended to be included in e.g. a tox.ini file
for testing of packages that rely on gtk2.0. under Linux.gtk is normally already installed on the target machine but not
available in any virtualenv. Installing withpipas dependency is
not possible.This package, during setup, will setup links to the relevant directories
(seemain()insetup.py).Typical use is to include the following dependency in yourtox.inifile:deps:
    pytest
    ruamel.venvgtkor you can install the links to gtk in your virtualenv by activating your
environment and doing:pip install ruamel.venvgtkYou don’t need to import from this package. Everything interesting
happens during installation!
Package: ruamel.yaml.base
YAMLBase class with saving, delayed loading and optional version supportThe YAMLBase class is initiated with apathlib.Pathor string based
filename of a document containing a single YAML file. This file needs
to exists unless thecreate_okparameter is supplied, in which case
an instance of the argument to that parameter is created (typically alistordictlike object) as the root of the data structure. If
the argument isTruean emptyruamel.yaml.CommentedMap()instance
is created as the root.Access to the root object is made via the.dataattribute, if an
existing file was specified, it is read in on the first access to.data.fromruamel.yaml.baseimportYAMLBasefile_name='/data0/talks/meta.yaml'base=YAMLBase(file_name,create_ok=True)base.data['PyCon 2006']=dict(location='Dallas, TX, USA',title='Extending the life of CVS with Python')base.data['EuroPython 2016']=dict(location='Bilbao, Spain',title='Beyond scraping')base.changed=Truebase.save()print(open(file_name).read())Which prints:PyCon 2006:
  location: Dallas, TX, USA
  title: Extending the life of CVS with Python
EuroPython 2016:
  location: Bilbao, Spain
  title: Beyond scrapingThe document is normally loaded usingruamel.yaml’s default round-trip mode. If
the initial access to an existing document is done via.fast_data, the loading
is done via the faster C loader (which is not fully YAML 1.2) compatible. In
that case you should not save the resulting file.Thesavewill not actually dump out the YAML document file, unless.changedhas been set toTrue. Saving to file sets.changedback toFalse. Using theforce=Truewill write to file independent ofchanged.
You can also add an extraoutargument, e.g. instead
of the last two lines in the example above, you could do:import sys
base.save(out=sys.stdout)  # not changing `.changed`
base.save()automatic savingIfYAMLBaseis initialised withauto_save=True,and.changedhas been
set the YAML file will be dumped when the object goes out of scope.internal progressThe initialisation has an optionalverboseargument which can be set to a positive
integer to get some information on what is going on internally.alternative initialisationWhen you subclassYAMLBase, you can pre set thecreate_okandauto_savevalues by setting
attributes before callingsuper():class X(YAMLBase):
    def __init__(self, path):
        self._create_ok = True
        self._auto_save = True
        super().__init__(path=path)
Package: ruamel.yaml.bytes
ruamel.yaml.bytesThis plug-in adds a methoddump_to_bytesto theruamel.yaml.YAMLinstance
that returns a (UTF-8) bytes arrayInstallationThe module can be installed from PyPI using:pip install ruamel.yaml.bytesThis module is dependent onruamel.yaml, so you do not have to explicitly
make your module depending on both.Usageimport ruamel.yaml

yaml = ruamel.yaml.YAML(typ=['rt', 'bytes'])
data  = dict(abc=42, help=['on', 'its', 'way'])
print('retval', yaml.dump_to_bytes(data).decode('utf-8'))
print('>>>> done')which gives:retval abc: 42
help:
- on
- its
- way
>>>> donePlease note that there is no final newline added to the bytes
array returned, and that the>>>>doneis on the next line is caused by
theprint()function adding a newline by default. Alternatively the
first call toprintcould be:print('retval', yaml.dump_to_bytes(data, add_final_eol=True).decode('utf-8'), end='')with the same effect..dump_to_bytes()can be shortened to.dumpb()ChangeLogNEXT:initial plug-in version
Package: ruamel.yaml.clib
ruamel.yaml.clibis the C based reader/scanner and emitter for ruamel.yamlversion:0.2.7updated:2022-10-19documentation:http://yaml.readthedocs.iorepository:https://sourceforge.net/projects/ruamel-yaml-clib/pypi:https://pypi.org/project/ruamel.yaml.clib/This package was split of from ruamel.yaml, so that ruamel.yaml can be build as
a universal wheel. Apart from the C code seldom changing, and taking a long
time to compile for all platforms, this allows installation of the .so
on Linux systems under /usr/lib64/pythonX.Y (without a .pth file or a ruamel
directory) and the Python code for ruamel.yaml under /usr/lib/pythonX.Y.This release in loving memory of Johanna Clasina van der Neut-Bandel [1922-10-19 - 2015-11-21]
Package: ruamel.yaml.cmd
This package provides theyamlcommandline utlity for converting to/from
YAML and for manipulating YAML filesBasic usage:yamlround-trip<file_name>for basic roundtrip testing of YAML
filesyaml json <file_name>for conversion of JSON file(s) to a single
YAML block style documentyaml json--write<file_name>to convert JSON files to individual .yaml files.
This is essential for being able to comparing otherwise unreadable JSON files
(e.g. single line metadata.json files in .whl distributions)yaml ini <file_name>for conversion of an INI/config file (ConfigObj
comment and nested sections supported) to a YAML block style document.
This requiresconfigobjto be installed (pip install ruamel.yaml.cmd[configobj])yamlfrom-csv<file_name>for conversion CSV to a YAML
file to a a table in an HTML file.yaml htmltable <file_name>for conversion of the basic structure in a YAML
file to a a table in an HTML file. The YAML file:title:
- fruit
- legume
local:
- apple
- sprouts
import:
- orange
- broccoliis converted into the table:titlefruitlegumelocalapplesproutsimportorangebroccoliyamlmerge-expand<input> <output>expand merges in input YAML file (use - for stdin/out)yaml pickle <input>load a pickle file (assuming your python version support the pickled data version).
If the object has ato_yaml`method it is registered and used for dumping.
If the object only has__getstate__or if--create-to-yamlis provided, a genericto_yamlis added that will dump the dict as a mapping with a tag.Seeyaml--helpfor more information on the availble commands
Package: ruamel.yaml.jinja2
ruamel.yaml.jinja2version:0.2.7updated:2021-09-23repository:https://sourceforge.net/projects/ruamel-yaml-jinja2/pypi:https://pypi.org/project/ruamel.yaml.jinja2/jinja2 templates for YAML files can normally not be loaded as YAML before
rendering the template. This plugin allows pre and post-processing based on the
round-trip processor.It works by rewriting the jinja2 constructs and keeping track of what needs to be “un-rewritten”
for this to work, you need to use the sameYAML()instance for loading and dumping.Its intended use is allowing you to update hardcoded values in the YAML file, and not to update
the jinja2 template part (which might even only be available in a comment).See, the bottom of,this StackOverflow answerorthis one.ChangeLog0.2.7 (2021-09-23):add link to example answers on SO, add badges to README0.2.6 (2021-09-23):fix README0.2.5 (2021-09-23):add support for “{{- “ in if-statementuser3170450 on stackoverflow0.2.4:fix spurious .pth file for nested package.0.2.3:handling jinja2 comments, PR supplied byJude N0.2.2 (2017-10-11):fix for Python 3.x0.2.1 (2017-06-23):add univeral wheel0.2.0 (2017-06-23):rename to __plug_in__.py0.1.3 (2017-06-18):remove generation of non-functional jinja2 executable0.1.2 (2017-06-16):added keyword, dependency on ruamel.yaml0.1.1 (2017-06-14):initial plug-in version
Package: ruamel.yaml.split
This package provides a YAML document splitter,
that allows you to iterate over a UTF-8 encoded file with YAML
documents, and that returns each
document, start linenumber and optionally loaded data.Using this has the advantage over usingload_all(), that you can skip individual documents
that you know don’t load, or that you test/transform before proper loading.
E.g.Rmarkdown files have a YAML header followed by a non-YAML body
(of course it would have been much better if inRmarkdown,
the header had been followed by---|instead of only a directory-end-marker (---),
that way you could useanycompliant YAML parser to load both)You can use the following to get to each document:frompathlibimportPathfromruamel.yaml.splitimportsplitfordoc,line_nrinsplit(Path('input.yaml')):print(doc.decode('utf-8'),line_nr)The line_nr indicates the starting line of the document and can be used as an offset
for e.g. errors that are generated when parsing the document.You can also provide aYAML()instance to get the document loaded for you:importruamel.yamlfordoc,data,line_nrinsplit(Path('input.yaml'),yaml=ruamel.yaml.YAML()):print(doc.decode('utf-8'),data,line_nr)theYAML()instance you provide is used to load all documents.By defaultsplit()splits on the line-ending after the document-end-marker (...), so that any comment
on the line of the document-end-marker is part of the document before it. Using
some constants imported fromruamel.yaml.splitthat you provide to the
thecmntparameter ofsplit(), you can influence where the comments “between” documents
are split.C_PREadds any such comments to the preceding document,C_POSTto
the following document.C_SPLIT_ON_FIRST_BLANK, splits after the first blank line and assigns to both.fromruamel.yaml.splitimportC_SPLIT_ON_FIRST_BLANKfordoc,data,line_nrinsplit(Path('input.yaml'),cmnt=C_SPLIT_ON_FIRST_BLANK):print(doc.decode('utf-8'),line_nr)Comments at the end of the
document stream are all attached to the last document, independent of thecmntparameter.
Package: ruamel.yaml.string
ruamel.yaml.stringversion:0.1.1updated:2023-05-02This plug-in adds a methoddump_to_string(and its equivalentdumps)
to theruamel.yaml.YAMLinstance that returns the document as
a Pythonstring.InstallationThe module can be installed from PyPI using:pip install ruamel.yaml.stringThis module is dependent onruamel.yaml, so you do not have to explicitly
make your module depending on both.Usageimportruamel.yamlyaml=ruamel.yaml.YAML(typ=['rt','string'])data=dict(abc=42,help=['on','its','way'])print('retval',yaml.dump_to_string(data))print('>>>> done')which gives:retval abc: 42
help:
- on
- its
- way
>>>> donePlease note that there is no final newline added to the string
that is returned. That the>>>>doneis on the next line is caused by
theprint()function adding a newline by default. (This is different
from using PyYAML’sdump, as e.g. the output of variousprint dump(data)examples in the documentation (2021) fail to clearly show the double newline at the
end of the examples output. It is similar tojson.dumps(data, indent=2)that returns
a string without final newline.)Alternatively the
first call toprintcould be:print('retval', yaml.dump_to_string(data, add_final_eol=True), end='')with the same effect..dump_to_string()can be shortened to.dumps()Directly writing to ``sys.stdout`` using ``yaml.dump(data, sys.stdout)`` is
much more efficient than ``print``-ing the result of ``yaml.dumps(data)``ChangeLog0.1.1 (2023-05-02):typing added and readme corrections0.1.0 (2022-03-17):initial plug-in version
Package: ruamel.zip2tar
zip2taris an in memory zip to tar convertor.No intermediate files are created on disc.
By default non-compressed tar is created, but can specify
commandline options to get gzip, bzip2 or xz compressed
tar archives.The output filename can be set explicitly with--tar-file-name, but is
normally derived by replacing “.zip” with “.tar”, “.tar.xz”,
“.tar.bz2” or “.tar.gz”.The--md5option adds a filemd5.sumto the tar file (a file with
that name cannot already be in the zip file). After extracting, you can domd5sum-cmd5.sumto check the files for corruption. These md5 sums are
calculated from the in-memory extracted data and arenotbased on the
zip’s CRC information.On Python 2.7 this requires ‘pyliblzma’usage: zip2tar [-h] [--verbose] [--xz] [--bz2] [--gz]
               [--compression-level COMPRESSION_LEVEL] [--no-datetime]
               [--tar-file-name NAME] [--md5] [--version]
               filename

in-memory zip to tar convertor

positional arguments:
  filename

optional arguments:
  -h, --help            show this help message and exit
  --verbose, -v         increase verbosity level
  --xz                  write xz compressed tar file
  --bz2                 write bzip2 compressed tar file
  --gz                  write gzip compressed tar file
  --compression-level COMPRESSION_LEVEL
  --no-datetime         don't take datetime for files from zip -> 1970-01-01
  --tar-file-name NAME  set tar file name (normally derived from .zip)
  --md5                 add a 'sum.md5' file (cannot already be in the zip)
  --version             show program's version number and exit