%\=FddlZddlZddlmZddlZejdZdZdedefdZde de fd Z de de fd Z d e fd Z de fd ZdefdZdZdZdS)N)Pathz([0-9]+)\.([0-9]+)\.([0-9]+)z \/:*?"<>|pathreturnct |tjS#t$r|cYSwxYw)zv Returns the path relative to the current working directory if possible. Otherwise return the path unchanged. ) relative_toosgetcwd ValueError)rs h/builddir/build/BUILD/cloudlinux-venv-1.0.10/venv/lib/python3.11/site-packages/pytest_snapshot/_utils.py shorten_pathr sE ,,,  s %( 77sct|dd}tjdd|}dddd||}|S) z Return the given string converted to a string that can be used for a clean filename. Taken from https://github.com/django/django/blob/master/django/utils/text.py  _z (?u)[^-\w.]emptydotdotdot)r...)strstripreplaceresubgetr s r get_valid_filenamers^ A sC((A ~r1%%A 51155a;;A Hctdkp+dkp%dkptfdtD S)a Returns false if the given string is definitely a path traversal or not a valid filename. Returns true if the string might be a valid filename. Note: This isn't secure, it just catches most accidental path traversals or invalid filenames. rrrc3 K|]}|vV dSN).0cr s r z*might_be_valid_filename..+s'66!qAv666666r)lenanyILLEGAL_FILENAME_CHARSrs`r might_be_valid_filenamer* s\ A!  7 8 7 9 7 66665666 6 6  rversionct|}|tdtd|DS)z Returns a 3 tuple of the versions major, minor, and patch. Raises a value error if the version string is unsupported. NzUnsupported version formatc34K|]}t|VdSr")int)r$parts r r&z'simple_version_parse..8s(66tT666666r)SIMPLE_VERSION_REGEXmatchr tuplegroups)r+r1s r simple_version_parser4/sP ! & &w / /E }5666 66u||~~666 6 66rcd ttj}|dkS#t$rYdSwxYw)z Returns true if pytest prints string diffs correctly for: assert tested_value == expected_value Returns false if pytest prints string diffs correctly for: assert expected_value == tested_value )rT)r4pytest __version__r )pytest_versions r _pytest_expected_on_rightr;;sH+-f.@AA** tts ! //dc\t|tusJg}t||g|S)a Returns the flattened dict representation of the given dict. Example: >>> flatten_dict({ ... 'a': 1, ... 'b': { ... 'c': 2 ... }, ... 'd': {}, ... }) [(['a'], 1), (['b', 'c'], 2)] )typedict _flatten_dict)r<results r flatten_dictrBNs3 77d???? F!VR   Mrc&t|turV|D]?\}}||t ||||@dS|t ||fdSr")r>r?itemsappendr@poplist)objrAprefixkvs r r@r@cs CyyDIIKK  DAq MM!    !VV , , , JJLLLL    tF||S)*****rc@i}t|D]\}}t|D]^\}}t|sJdd|d|D}t d||_||d|<|S)a Returns the flattened dict of a nested dictionary structure describing a filesystem. Raises ``ValueError`` if any of the dictionary keys are invalid filenames. Example: >>> flatten_filesystem_dict({ ... 'file1.txt': '111', ... 'dir1': { ... 'file2.txt': '222' ... }, ... }) {'file1.txt': '111', 'dir1/file2.txt': '222'} rc3@K|]}d|VdS)z[{!r}]N)format)r$rJs r r&z*flatten_filesystem_dict..s.&P&Paxq'9'9&P&P&P&P&P&PrNz*Key {!r} in d{} must be a valid file name./)rB enumerater*joinr rN)r<rAkey_listrHikey key_list_strs r flatten_filesystem_dictrVms F%a)) #)) i iFAs*3// i!ww&P&P8BQB<&P&P&PPP  !M!T!TUXZf!g!ghhh i&)sxx!!"" Mr)rrpathlibrr8compiler0r)r rrboolr*r4r;r?rBr@rVr#rr rZs*  !rz"ABB%t # #     s t     7# 7 7 7 7+4++++&D*+++r