本文整理汇总了Python中os.path.lower方法的典型用法代码示例。如果您正苦于以下问题:Python path.lower方法的具体用法?Python path.lower怎么用?Python path.lower使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类os.path
的用法示例。
在下文中一共展示了path.lower方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _CopyOrLink
# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import lower [as 别名]
def _CopyOrLink(self, source_dir, stage_dir, static_dir, inside_web_inf):
source_dir = os.path.abspath(source_dir)
stage_dir = os.path.abspath(stage_dir)
static_dir = os.path.abspath(static_dir)
for file_name in os.listdir(source_dir):
file_path = os.path.join(source_dir, file_name)
if file_name.startswith('.') or file_name == 'appengine-generated':
continue
if os.path.isdir(file_path):
self._CopyOrLink(
file_path,
os.path.join(stage_dir, file_name),
os.path.join(static_dir, file_name),
inside_web_inf or file_name == 'WEB-INF')
else:
if (inside_web_inf
or self.app_engine_web_xml.IncludesResource(file_path)
or (self.options.compile_jsps
and file_path.lower().endswith('.jsp'))):
self._CopyOrLinkFile(file_path, os.path.join(stage_dir, file_name))
if (not inside_web_inf
and self.app_engine_web_xml.IncludesStatic(file_path)):
self._CopyOrLinkFile(file_path, os.path.join(static_dir, file_name))
示例2: open_file
# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import lower [as 别名]
def open_file(self, path):
"""
Tries to open a MicroPython hex file with an embedded Python script.
Returns the embedded Python script and newline convention.
"""
text = None
if path.lower().endswith(".hex"):
# Try to open the hex and extract the Python script
try:
with open(path, newline="") as f:
text = uflash.extract_script(f.read())
except Exception:
return None, None
return text, sniff_newline_convention(text)
else:
return None, None
示例3: index
# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import lower [as 别名]
def index(self):
return TEMPLATE_FRAMESET % self.root.lower()
示例4: menu
# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import lower [as 别名]
def menu(self, base='/', pct='50', showpct='',
exclude=r'python\d\.\d|test|tut\d|tutorial'):
# The coverage module uses all-lower-case names.
base = base.lower().rstrip(os.sep)
yield TEMPLATE_MENU
yield TEMPLATE_FORM % locals()
# Start by showing links for parent paths
yield "<div id='crumbs'>"
path = ''
atoms = base.split(os.sep)
atoms.pop()
for atom in atoms:
path += atom + os.sep
yield ("<a href='menu?base=%s&exclude=%s'>%s</a> %s"
% (path, urllib.parse.quote_plus(exclude), atom, os.sep))
yield '</div>'
yield "<div id='tree'>"
# Then display the tree
tree = get_tree(base, exclude, self.coverage)
if not tree:
yield '<p>No modules covered.</p>'
else:
for chunk in _show_branch(tree, base, '/', pct,
showpct == 'checked', exclude,
coverage=self.coverage):
yield chunk
yield '</div>'
yield '</body></html>'
示例5: openFileByType
# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import lower [as 别名]
def openFileByType(self, mime, path, lineNo=-1):
"""Opens editor/browser suitable for the file type"""
path = os.path.abspath(path)
if not os.path.exists(path):
logging.error("Cannot open %s, does not exist", path)
return
if os.path.islink(path):
path = os.path.realpath(path)
if not os.path.exists(path):
logging.error("Cannot open %s, does not exist", path)
return
# The type may differ...
mime, _, _ = getFileProperties(path)
else:
# The intermediate directory could be a link, so use the real path
path = os.path.realpath(path)
if not os.access(path, os.R_OK):
logging.error("No read permissions to open %s", path)
return
if not os.path.isfile(path):
logging.error("%s is not a file", path)
return
if isImageViewable(mime):
self.openPixmapFile(path)
return
if mime != 'inode/x-empty' and not isFileSearchable(path):
logging.error("Cannot open non-text file for editing")
return
if path.lower().endswith('readme'):
print(path)
print(mime)
self.openFile(path, lineNo)
示例6: _onStyle
# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import lower [as 别名]
def _onStyle(self, styleName):
"""Sets the selected style"""
QApplication.setStyle(styleName.data())
self.settings['style'] = styleName.data().lower()
示例7: menu
# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import lower [as 别名]
def menu(self, base="/", pct="50", showpct="",
exclude=r'python\d\.\d|test|tut\d|tutorial'):
# The coverage module uses all-lower-case names.
base = base.lower().rstrip(os.sep)
yield TEMPLATE_MENU
yield TEMPLATE_FORM % locals()
# Start by showing links for parent paths
yield "<div id='crumbs'>"
path = ""
atoms = base.split(os.sep)
atoms.pop()
for atom in atoms:
path += atom + os.sep
yield ("<a href='menu?base=%s&exclude=%s'>%s</a> %s"
% (path, quote_plus(exclude), atom, os.sep))
yield "</div>"
yield "<div id='tree'>"
# Then display the tree
tree = get_tree(base, exclude, self.coverage)
if not tree:
yield "<p>No modules covered.</p>"
else:
for chunk in _show_branch(tree, base, "/", pct,
showpct == 'checked', exclude,
coverage=self.coverage):
yield chunk
yield "</div>"
yield "</body></html>"
示例8: match_path
# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import lower [as 别名]
def match_path(path, patterns, abspath=0, case_sensitive=1):
if case_sensitive:
match_func = fnmatch.fnmatchcase
transform = os.path.abspath if abspath else lambda s: s
else:
match_func = fnmatch.fnmatch
path = path.lower()
transform = (lambda p: os.path.abspath(p.lower())) if abspath else string.lower
return any(match_func(path, transform(pattern)) for pattern in patterns)
示例9: _ShouldSplitJar
# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import lower [as 别名]
def _ShouldSplitJar(self, path):
return (path.lower().endswith('.jar') and self.options.do_jar_splitting and
os.path.getsize(path) >= self._MAX_SIZE)
示例10: username_to_url
# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import lower [as 别名]
def username_to_url(username):
return "https://likee.com/@" + username.lower()
示例11: normalize_video_page_url
# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import lower [as 别名]
def normalize_video_page_url(url):
return url.replace("/trending/@", "/@").lower()
示例12: on_double_click
# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import lower [as 别名]
def on_double_click(self, event):
path = self.get_selected_path()
kind = self.get_selected_kind()
parts = path.split(".")
ext = "." + parts[-1]
if path.endswith(ext) and kind == "file" and ext.lower() in TEXT_EXTENSIONS:
self.open_file(path)
elif kind == "dir":
self.request_focus_into(path)
return "break"
示例13: _add_to_path
# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import lower [as 别名]
def _add_to_path(directory, path):
# Always prepending to path may seem better, but this could mess up other things.
# If the directory contains only one Python distribution executables, then
# it probably won't be in path yet and therefore will be prepended.
if (
directory in path.split(os.pathsep)
or platform.system() == "Windows"
and directory.lower() in path.lower().split(os.pathsep)
):
return path
else:
return directory + os.pathsep + path
示例14: _get_linux_terminal_command
# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import lower [as 别名]
def _get_linux_terminal_command():
import shutil
xte = shutil.which("x-terminal-emulator")
if xte:
if os.path.realpath(xte).endswith("/lxterminal") and shutil.which("lxterminal"):
# need to know exact program, because it needs special treatment
return "lxterminal"
elif os.path.realpath(xte).endswith("/terminator") and shutil.which("terminator"):
# https://github.com/thonny/thonny/issues/1129
return "terminator"
else:
return "x-terminal-emulator"
# Older konsole didn't pass on the environment
elif shutil.which("konsole"):
if (
shutil.which("gnome-terminal")
and "gnome" in os.environ.get("DESKTOP_SESSION", "").lower()
):
return "gnome-terminal"
else:
return "konsole"
elif shutil.which("gnome-terminal"):
return "gnome-terminal"
elif shutil.which("xfce4-terminal"):
return "xfce4-terminal"
elif shutil.which("lxterminal"):
return "lxterminal"
elif shutil.which("xterm"):
return "xterm"
else:
raise RuntimeError("Don't know how to open terminal emulator")
示例15: _is_interesting_module_file
# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import lower [as 别名]
def _is_interesting_module_file(self, path):
# interesting files are the files in the same directory as main module
# or the ones with breakpoints
# When command is "resume", then only modules with breakpoints are interesting
# (used to be more flexible, but this caused problems
# when main script was in ~/. Then user site library became interesting as well)
result = self._file_interest_cache.get(path, None)
if result is not None:
return result
_, extension = os.path.splitext(path.lower())
result = (
self._get_breakpoints_in_file(path)
or self._main_module_path is not None
and is_same_path(path, self._main_module_path)
or extension in (".py", ".pyw")
and (
self._current_command.get("allow_stepping_into_libraries", False)
or (
path_startswith(path, os.path.dirname(self._main_module_path))
# main module may be at the root of the fs
and not path_startswith(path, sys.prefix)
and not path_startswith(path, sys.base_prefix)
and not path_startswith(path, site.getusersitepackages() or "usersitenotexists")
)
)
and not path_startswith(path, self._thonny_src_dir)
)
self._file_interest_cache[path] = result
return result