def run(self, edit, which=None): assert which in ('file', 'directory'), "which: " + which self.index = self.get_all() rel_path = relative_path(self.get_selected(parent=False) or '') self.which = which self.refresh = True pv = self.view.window().show_input_panel(which.capitalize() + ':', rel_path, self.on_done, None, None) pv.run_command('move_to', {'to': 'eol', 'extend': False}) pv.settings().set('dired_create', True) pv.settings().set('which', which) pv.settings().set('dired_path', self.path)
def run(self, edit): s = self.view.settings() sources_move = s.get('dired_to_move', []) sources_copy = s.get('dired_to_copy', []) if not (sources_move or sources_copy): return sublime.status_message('Nothing to paste') self.index = self.get_all() path = self.get_path() rel_path = relative_path(self.get_selected(parent=False) or '') destination = join(path, rel_path) or path if NT: return call_SHFileOperationW(self.view, sources_move, sources_copy, destination) else: return call_SystemAgnosticFileOperation(self.view, sources_move, sources_copy, destination)
def get_station(args, input_file, stations): path = 'resources/promice/aliases.txt' aliases = {} with open(common.relative_path(path)) as stream: for line in stream.readlines(): if not line.strip(): continue bits = re.split('[,:]', line) bits = [i.strip() for i in bits if i.strip()] for b in bits[:-1]: aliases[b] = bits[-1] filename = os.path.basename(input_file) for key, value in aliases.items(): if key in filename: return common.parse_station(args, stations[value])
def get_stations(): """Read stations.txt and parse it into an ordered dict.""" with open(relative_path('resources/stations.txt')) as stream: stations = stream.read().split('\n') # remove blank lines stations = [i.strip() for i in stations if i.strip()] ordered = collections.OrderedDict(blank=[]) errmsg = 'stations.txt is corrupted or malformed and could not be parsed.' for station in stations: match = re.match('(.+) +(-?[0-9.]+) + (-?[0-9.]+) *(.*)$', station) if not match: raise RuntimeError(errmsg) name, lon, lat, name2 = match.groups() lon, lat = float(lon), float(lat) name2 = name2.strip() value = [lon, lat, name2] if name2 else [lon, lat] ordered[name.strip()] = value return ordered