File: utils.py

package info (click to toggle)
pyftpd 0.8.1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 524 kB
  • ctags: 448
  • sloc: python: 2,748; sh: 80; makefile: 43
file content (30 lines) | stat: -rw-r--r-- 879 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import os, os.path, fnmatch, sys, string

emulate_posix=0

if sys.platform[:3] == 'win':
    import posixpath
    myfnmatch = fnmatch.fnmatch
    defaultdir = "c:\\"
    def isdir(path): # kludge to recognize single drive letters as directory
        # path is already real fs path
        return os.path.isdir(path) or (len(path)==2 and path[1]==':' and path[0] in string.letters)
    def isexec(path): # see if path is executable
        return ( isdir(path) or 
                 (os.path.splitext(string.lower(path))[1] in (".exe", ".com", ".bat"))
                )
                
else:
    myfnmatch = fnmatch.fnmatchcase
    defaultdir = "/"
    isdir = os.path.isdir
    def isexec(path):
        try:
            r = os.access(path, 1)
        except:
            try:
                r = isdir(path)
            except:
                r = 0
        return r