text stringlengths 0 828 |
|---|
return subject" |
581,"def rmvsuffix(subject): |
"""""" |
Remove the suffix from *subject*. |
"""""" |
index = subject.rfind('.') |
if index > subject.replace('\\', '/').rfind('/'): |
subject = subject[:index] |
return subject" |
582,"def getsuffix(subject): |
"""""" |
Returns the suffix of a filename. If the file has no suffix, returns None. |
Can return an empty string if the filenam ends with a period. |
"""""" |
index = subject.rfind('.') |
if index > subject.replace('\\', '/').rfind('/'): |
return subject[index+1:] |
return None" |
583,"def makedirs(path, exist_ok=True): |
"""""" |
Like #os.makedirs(), with *exist_ok* defaulting to #True. |
"""""" |
try: |
os.makedirs(path) |
except OSError as exc: |
if exist_ok and exc.errno == errno.EEXIST: |
return |
raise" |
584,"def chmod_update(flags, modstring): |
"""""" |
Modifies *flags* according to *modstring*. |
"""""" |
mapping = { |
'r': (_stat.S_IRUSR, _stat.S_IRGRP, _stat.S_IROTH), |
'w': (_stat.S_IWUSR, _stat.S_IWGRP, _stat.S_IWOTH), |
'x': (_stat.S_IXUSR, _stat.S_IXGRP, _stat.S_IXOTH) |
} |
target, direction = 'a', None |
for c in modstring: |
if c in '+-': |
direction = c |
continue |
if c in 'ugoa': |
target = c |
direction = None # Need a - or + after group specifier. |
continue |
if c in 'rwx' and direction in '+-': |
if target == 'a': |
mask = functools.reduce(operator.or_, mapping[c]) |
else: |
mask = mapping[c]['ugo'.index(target)] |
if direction == '-': |
flags &= ~mask |
else: |
flags |= mask |
continue |
raise ValueError('invalid chmod: {!r}'.format(modstring)) |
return flags" |
585,"def chmod_repr(flags): |
"""""" |
Returns a string representation of the access flags *flags*. |
"""""" |
template = 'rwxrwxrwx' |
order = (_stat.S_IRUSR, _stat.S_IWUSR, _stat.S_IXUSR, |
_stat.S_IRGRP, _stat.S_IWGRP, _stat.S_IXGRP, |
_stat.S_IROTH, _stat.S_IWOTH, _stat.S_IXOTH) |
return ''.join(template[i] if flags&x else '-' |
for i, x in enumerate(order))" |
586,"def compare_timestamp(src, dst): |
"""""" |
Compares the timestamps of file *src* and *dst*, returning #True if the |
*dst* is out of date or does not exist. Raises an #OSError if the *src* |
file does not exist. |
"""""" |
try: |
dst_time = os.path.getmtime(dst) |
except OSError as exc: |
if exc.errno == errno.ENOENT: |
return True # dst does not exist |
src_time = os.path.getmtime(src) |
return src_time > dst_time" |
587,"def init_app(self, app): |
""""""Initialize the extension."""""" |
# Set default Flask config option. |
app.config.setdefault('STATICS_MINIFY', False) |
# Select resources. |
self.all_resources = ALL_RESOURCES_MINIFIED if app.config.get('STATICS_MINIFY') else ALL_RESOURCES |
self.all_variables = ALL_VARIABLES |
# Add this instance to app.extensions. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.