def find_sequence_paths(filepath, use_fullpath=True): # supports str, byte paths basedir, filename = os.path.split(filepath) if not os.path.exists(basedir): return [] filename_noext, ext = os.path.splitext(filename) from string import digits if isinstance(filepath, bytes): digits = digits.encode() filename_nodigits = filename_noext.rstrip(digits) if len(filename_nodigits) == len(filename_noext): # input isn't from a sequence return [] files = os.listdir(basedir) files[:] = [ f for f in files if f.startswith(filename_nodigits) and f.endswith(ext) and f[len(filename_nodigits):-len(ext) if ext else -1].isdigit() ] if use_fullpath: files[:] = [ os.path.join(basedir, f) for f in files ] return files
CRLF = '\r\n' NL = '\n' EMPTYSTRING = '' # Build a mapping of octets to the expansion of that octet. Since we're only # going to have 256 of these things, this isn't terribly inefficient # space-wise. Remember that headers and bodies have different sets of safe # characters. Initialize both maps with the full expansion, and then override # the safe bytes with the more compact form. _QUOPRI_MAP = ['=%02X' % c for c in range(256)] _QUOPRI_HEADER_MAP = _QUOPRI_MAP[:] _QUOPRI_BODY_MAP = _QUOPRI_MAP[:] # Safe header bytes which need no encoding. for c in b'-!*+/' + ascii_letters.encode('ascii') + digits.encode('ascii'): _QUOPRI_HEADER_MAP[c] = chr(c) # Headers have one other special encoding; spaces become underscores. _QUOPRI_HEADER_MAP[ord(' ')] = '_' # Safe body bytes which need no encoding. for c in (b' !"#$%&\'()*+,-./0123456789:;<>' b'?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`' b'abcdefghijklmnopqrstuvwxyz{|}~\t'): _QUOPRI_BODY_MAP[c] = chr(c) # Helpers def header_check(octet): """Return True if the octet should be escaped with header quopri."""
from DateTime.DateTime import DateTime from OFS.Folder import Folder from OFS.Image import File from .common import FilesystemTestBase from .common import TarballTester from .conformance import ConformsToISetupContext from .conformance import ConformsToIImportContext from .conformance import ConformsToIExportContext from .conformance import ConformsToIChunkableExportContext from .conformance import ConformsToIChunkableImportContext printable_bytes = printable.encode('utf-8') digits_bytes = digits.encode('utf-8') class DummySite(Folder): pass class DummyTool(Folder): pass class DummyPdataStreamIterator: pass
from string import ascii_letters, digits, hexdigits CRLF = "\r\n" NL = "\n" EMPTYSTRING = "" # Build a mapping of octets to the expansion of that octet. Since we're only # going to have 256 of these things, this isn't terribly inefficient # space-wise. Remember that headers and bodies have different sets of safe # characters. Initialize both maps with the full expansion, and then override # the safe bytes with the more compact form. _QUOPRI_HEADER_MAP = dict((c, "=%02X" % c) for c in range(256)) _QUOPRI_BODY_MAP = _QUOPRI_HEADER_MAP.copy() # Safe header bytes which need no encoding. for c in b"-!*+/" + ascii_letters.encode("ascii") + digits.encode("ascii"): _QUOPRI_HEADER_MAP[c] = chr(c) # Headers have one other special encoding; spaces become underscores. _QUOPRI_HEADER_MAP[ord(" ")] = "_" # Safe body bytes which need no encoding. for c in b" !\"#$%&'()*+,-./0123456789:;<>" b"?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`" b"abcdefghijklmnopqrstuvwxyz{|}~\t": _QUOPRI_BODY_MAP[c] = chr(c) # Helpers def header_check(octet): """Return True if the octet should be escaped with header quopri.""" return chr(octet) != _QUOPRI_HEADER_MAP[octet]
from string import ascii_letters, digits, hexdigits CRLF = '\r\n' NL = '\n' EMPTYSTRING = '' # Build a mapping of octets to the expansion of that octet. Since we're only # going to have 256 of these things, this isn't terribly inefficient # space-wise. Remember that headers and bodies have different sets of safe # characters. Initialize both maps with the full expansion, and then override # the safe bytes with the more compact form. _QUOPRI_HEADER_MAP = dict((c, '=%02X' % c) for c in range(256)) _QUOPRI_BODY_MAP = _QUOPRI_HEADER_MAP.copy() # Safe header bytes which need no encoding. for c in b'-!*+/' + ascii_letters.encode('ascii') + digits.encode('ascii'): _QUOPRI_HEADER_MAP[c] = chr(c) # Headers have one other special encoding; spaces become underscores. _QUOPRI_HEADER_MAP[ord(' ')] = '_' # Safe body bytes which need no encoding. for c in (b' !"#$%&\'()*+,-./0123456789:;<>' b'?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`' b'abcdefghijklmnopqrstuvwxyz{|}~\t'): _QUOPRI_BODY_MAP[c] = chr(c) # Helpers def header_check(octet): """Return True if the octet should be escaped with header quopri.""" return chr(octet) != _QUOPRI_HEADER_MAP[octet]