PageRenderTime 49ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/documentation_files/fnmatch.py

https://github.com/kensington/kdevelop-python
Python | 67 lines | 25 code | 13 blank | 29 comment | 7 complexity | 6344d204c6c8caadcd1c234725d749b8 MD5 | raw file
  1. #!/usr/bin/env python2.7
  2. # -*- coding: utf-8 -*-
  3. """:synopsis: Unix shell style filename pattern matching.
  4. """
  5. def fnmatch(filename,pattern):
  6. """
  7. Test whether the *filename* string matches the *pattern* string, returning
  8. :const:`True` or :const:`False`. If the operating system is case-insensitive,
  9. then both parameters will be normalized to all lower- or upper-case before
  10. the comparison is performed. :func:`fnmatchcase` can be used to perform a
  11. case-sensitive comparison, regardless of whether that's standard for the
  12. operating system.
  13. This example will print all file names in the current directory with the
  14. extension ``.txt``::
  15. import fnmatch
  16. import os
  17. for file in os.listdir('.'):
  18. if fnmatch.fnmatch(file, '*.txt'):
  19. print file
  20. """
  21. pass
  22. def fnmatchcase(filename,pattern):
  23. """
  24. Test whether *filename* matches *pattern*, returning :const:`True` or
  25. :const:`False`; the comparison is case-sensitive.
  26. """
  27. pass
  28. def filter(names,pattern):
  29. """
  30. Return the subset of the list of *names* that match *pattern*. It is the same as
  31. ``[n for n in names if fnmatch(n, pattern)]``, but implemented more efficiently.
  32. """
  33. pass
  34. def translate(pattern):
  35. """
  36. Return the shell-style *pattern* converted to a regular expression.
  37. Be aware there is no way to quote meta-characters.
  38. Example:
  39. >>> import fnmatch, re
  40. >>>
  41. >>> regex = fnmatch.translate('*.txt')
  42. >>> regex
  43. '.*\\.txt$'
  44. >>> reobj = re.compile(regex)
  45. >>> reobj.match('foobar.txt')
  46. <_sre.SRE_Match object at 0xmore>
  47. """
  48. pass