Python os.path.lower() Examples
The following are 30
code examples of os.path.lower().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
os.path
, or try the search function
.
Example #1
Source File: microbit.py From mu with GNU General Public License v3.0 | 6 votes |
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
Example #2
Source File: appcfg_java.py From python-compat-runtime with Apache License 2.0 | 6 votes |
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))
Example #3
Source File: terminal.py From thonny with MIT License | 5 votes |
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")
Example #4
Source File: covercp.py From moviegrabber with GNU General Public License v3.0 | 5 votes |
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>"
Example #5
Source File: covercp.py From moviegrabber with GNU General Public License v3.0 | 5 votes |
def index(self): return TEMPLATE_FRAMESET % self.root.lower()
Example #6
Source File: windows.py From maas with GNU Affero General Public License v3.0 | 5 votes |
def match_path(self, backend, path): """Checks path to see if the boot method should handle the requested file. :param backend: requesting backend :param path: requested path :return: dict of match params from path, None if no match """ # If the node is requesting the initial bootloader, then we # need to see if this node is set to boot Windows first. local_host, local_port = tftp.get_local_address() if path in ["pxelinux.0", "lpxelinux.0"]: data = yield self.get_node_info() if data is None: return None # Only provide the Windows bootloader when installing # PXELINUX chainloading will work for the rest of the time. purpose = data.get("purpose") if purpose != "install": return None osystem = data.get("osystem") if osystem == "windows": # python-hivex is needed to continue. if get_hivex_module() is None: raise BootMethodError("python-hivex package is missing.") return { "mac": data.get("mac"), "path": self.bootloader_path, "local_host": local_host, } # Fix the paths for the other static files, Windows requests. elif path.lower() in STATIC_FILES: return { "mac": get_remote_mac(), "path": self.clean_path(path), "local_host": local_host, }
Example #7
Source File: windows.py From maas with GNU Affero General Public License v3.0 | 5 votes |
def clean_path(self, path): """Converts Windows path into a unix path and strips the boot subdirectory from the paths. """ path = path.lower().replace("\\", "/") if path[0:6] == "/boot/": path = path[6:] return path
Example #8
Source File: covercp.py From Tautulli with GNU General Public License v3.0 | 5 votes |
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>'
Example #9
Source File: covercp.py From Tautulli with GNU General Public License v3.0 | 5 votes |
def index(self): return TEMPLATE_FRAMESET % self.root.lower()
Example #10
Source File: covercp.py From bazarr with GNU General Public License v3.0 | 5 votes |
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>'
Example #11
Source File: covercp.py From bazarr with GNU General Public License v3.0 | 5 votes |
def index(self): return TEMPLATE_FRAMESET % self.root.lower()
Example #12
Source File: animation.py From meshcat-python with MIT License | 5 votes |
def lower(self): return [{ u"path": path.lower(), u"clip": clip.lower() } for (path, clip) in self.clips.items()]
Example #13
Source File: animation.py From meshcat-python with MIT License | 5 votes |
def lower(self): return { u"fps": self.fps, u"name": unicode(self.name), u"tracks": [t.lower() for t in self.tracks.values()] }
Example #14
Source File: animation.py From meshcat-python with MIT License | 5 votes |
def lower(self): return { u"name": unicode("." + self.name), u"type": unicode(self.jstype), u"keys": [{ u"time": self.frames[i], u"value": self.values[i] } for i in range(len(self.frames))] }
Example #15
Source File: backend.py From thonny with MIT License | 5 votes |
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
Example #16
Source File: terminal.py From thonny with MIT License | 5 votes |
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
Example #17
Source File: covercp.py From opsbro with MIT License | 5 votes |
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>"
Example #18
Source File: covercp.py From cherrypy with BSD 3-Clause "New" or "Revised" License | 5 votes |
def index(self): return TEMPLATE_FRAMESET % self.root.lower()
Example #19
Source File: covercp.py From cherrypy with BSD 3-Clause "New" or "Revised" License | 5 votes |
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>'
Example #20
Source File: mainwindow.py From codimension with GNU General Public License v3.0 | 5 votes |
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)
Example #21
Source File: mainwindow.py From codimension with GNU General Public License v3.0 | 5 votes |
def _onStyle(self, styleName): """Sets the selected style""" QApplication.setStyle(styleName.data()) self.settings['style'] = styleName.data().lower()
Example #22
Source File: covercp.py From opsbro with MIT License | 5 votes |
def index(self): return TEMPLATE_FRAMESET % self.root.lower()
Example #23
Source File: base_file_browser.py From thonny with MIT License | 5 votes |
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"
Example #24
Source File: path.py From owasp-pysec with Apache License 2.0 | 5 votes |
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)
Example #25
Source File: appcfg_java.py From python-compat-runtime with Apache License 2.0 | 5 votes |
def _ShouldSplitJar(self, path): return (path.lower().endswith('.jar') and self.options.do_jar_splitting and os.path.getsize(path) >= self._MAX_SIZE)
Example #26
Source File: likee.py From rssit with MIT License | 5 votes |
def username_to_url(username): return "https://likee.com/@" + username.lower()
Example #27
Source File: likee.py From rssit with MIT License | 5 votes |
def normalize_video_page_url(url): return url.replace("/trending/@", "/@").lower()
Example #28
Source File: main.py From plugin.video.iptv.recorder with GNU General Public License v3.0 | 4 votes |
def recordings(): dir = plugin.get_setting('recordings') found_files = find_files(dir) items = [] starts = [] for path in found_files: try: json_file = path[:-3]+'.json' info = json.loads(xbmcvfs.File(json_file).read()) programme = info["programme"] title = programme['title'] sub_title = programme['sub_title'] or '' episode = programme['episode'] date = "(%s)" % programme['date'] or '' start = programme['start'] starts.append(start) if episode and episode != "MOVIE": label = "%s [COLOR grey]%s[/COLOR] %s" % (title, episode, sub_title) elif episode == "MOVIE": label = "%s %s" % (title,date) else: label = "%s %s" % (title, sub_title) description = programme['description'] except: label = os.path.splitext(os.path.basename(path))[0] description = "" starts.append("0") label = urllib.unquote_plus(label) label = label.decode("utf8") context_items = [] context_items.append((_("Delete Recording"), 'XBMC.RunPlugin(%s)' % (plugin.url_for(delete_recording, label=label.encode("utf8"), path=path)))) context_items.append((_("Delete All Recordings"), 'XBMC.RunPlugin(%s)' % (plugin.url_for(delete_all_recordings)))) if plugin.get_setting('external.player'): context_items.append((_("External Player"), 'XBMC.RunPlugin(%s)' % (plugin.url_for(play_external, path=path)))) #context_items.append((_("Convert to mp4"), 'XBMC.RunPlugin(%s)' % (plugin.url_for(convert, path=path)))) items.append({ 'label': label, 'path': path, 'is_playable': True, 'context_menu': context_items, 'info_type': 'Video', 'info':{"title": label, "plot":description}, }) xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_UNSORTED ) xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_LABEL ) xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_DATE ) start_items = zip(starts,items) start_items.sort(reverse=True) items = [x for y, x in start_items] return sorted(items, key=lambda k: k['label'].lower())
Example #29
Source File: covercp.py From bazarr with GNU General Public License v3.0 | 4 votes |
def _show_branch(root, base, path, pct=0, showpct=False, exclude='', coverage=the_coverage): # Show the directory name and any of our children dirs = [k for k, v in root.items() if v] dirs.sort() for name in dirs: newpath = os.path.join(path, name) if newpath.lower().startswith(base): relpath = newpath[len(base):] yield '| ' * relpath.count(os.sep) yield ( "<a class='directory' " "href='menu?base=%s&exclude=%s'>%s</a>\n" % (newpath, quote_plus(exclude), name) ) for chunk in _show_branch( root[name], base, newpath, pct, showpct, exclude, coverage=coverage ): yield chunk # Now list the files if path.lower().startswith(base): relpath = path[len(base):] files = [k for k, v in root.items() if not v] files.sort() for name in files: newpath = os.path.join(path, name) pc_str = '' if showpct: try: _, statements, _, missing, _ = coverage.analysis2(newpath) except: # Yes, we really want to pass on all errors. pass else: pc = _percent(statements, missing) pc_str = ('%3d%% ' % pc).replace(' ', ' ') if pc < float(pct) or pc == -1: pc_str = "<span class='fail'>%s</span>" % pc_str else: pc_str = "<span class='pass'>%s</span>" % pc_str yield TEMPLATE_ITEM % ('| ' * (relpath.count(os.sep) + 1), pc_str, newpath, name)
Example #30
Source File: covercp.py From Tautulli with GNU General Public License v3.0 | 4 votes |
def _show_branch(root, base, path, pct=0, showpct=False, exclude='', coverage=the_coverage): # Show the directory name and any of our children dirs = [k for k, v in root.items() if v] dirs.sort() for name in dirs: newpath = os.path.join(path, name) if newpath.lower().startswith(base): relpath = newpath[len(base):] yield '| ' * relpath.count(os.sep) yield ( "<a class='directory' " "href='menu?base=%s&exclude=%s'>%s</a>\n" % (newpath, urllib.parse.quote_plus(exclude), name) ) for chunk in _show_branch( root[name], base, newpath, pct, showpct, exclude, coverage=coverage ): yield chunk # Now list the files if path.lower().startswith(base): relpath = path[len(base):] files = [k for k, v in root.items() if not v] files.sort() for name in files: newpath = os.path.join(path, name) pc_str = '' if showpct: try: _, statements, _, missing, _ = coverage.analysis2(newpath) except Exception: # Yes, we really want to pass on all errors. pass else: pc = _percent(statements, missing) pc_str = ('%3d%% ' % pc).replace(' ', ' ') if pc < float(pct) or pc == -1: pc_str = "<span class='fail'>%s</span>" % pc_str else: pc_str = "<span class='pass'>%s</span>" % pc_str yield TEMPLATE_ITEM % ('| ' * (relpath.count(os.sep) + 1), pc_str, newpath, name)