def archive_file(input_file_name, path): """ This function simply moves one file to another location. Its purpose is to move the xml file after it has undergone conversion to the archival path. """ mv(input_file_name, path + input_file_name)
def save(self): if not os.path.exists(self.destination) or not os.path.isdir(self.destination): os.mkdir(self.destination) logging.info("Created a new directory for your tracked files at %s", self.destination) # TODO: Figure out how to copy shit os.mv(self.source, self.destination) os.symlink(self.source, self.destination) os.remove(self.source) logging.info("Successfully copied and symlink'd %s to %s", self.source, self.destination)
def move(self, new_basedir, path_format): formatted_path = path_format.format(**self.tags) new_dir = os.join(new_basedir, formatted_path) try: mkdir_p(new_dir) except OSError: logging.info("Directory %s already exist" % new_dir) #extract the extension try: ext = self.get_extension() except: # TODO specify error logging.error("Moving file %s failed, extension is undefined" % self.path) return formatted_path = path_format.format(self.tags) new_filename = os.path.join(new_basedir, formatted_path + ext) try: os.mv(self.path, new_filename) except OSError: logging.error("Moving file %s failed, cannot move the file")
def rename(direc, db, files): ''' This isn't really for bioinformatics, this is more for the pipeline, to rename the files generated by cluster.py with a little human interaction. ''' names = [] seqdb = dict((s.name, s) for s in io.open(db, 'r')) nt_dir, aa_dir = direc + 'nt' + sep, direc + 'aa' + sep for f in files: seq = io.open(nt_dir + f, 'r').next() ids = seq.defline.split(', ') print("File\033[33;1m", f, \ "\033[0mis described by the following sequences:") try: for id in ids: seqdb[id] print("* " + seqdb[id].name + ': ' + seqdb[id].defline.split('[')[0]) except KeyError: print("* (none)") continue pre = get_input("\033[33;1mWhat should we call this file " + "(or hit enter to skip)? \033[0m") fpre = f[:f.find('.')] if pre != "": count = 0 while True: rpre = pre + ((" (%d)" % count) if count > 0 else "") try: fh = open(nt_dir + rpre + ".fasta", 'r') fh.close() count += 1 continue except IOError: nt_old, nt_new = nt_dir + fpre, nt_dir + rpre aa_old, aa_new = aa_dir + fpre, aa_dir + rpre print("Renaming " + fpre + ".* to " + rpre + ".*") try: mv(nt_old + ".fasta", nt_new + ".fasta") mv(aa_old + ".fasta", aa_new + ".fasta") mv(nt_old + ".clustalw", nt_new + ".clustalw") mv(aa_old + ".clustalw", aa_new + ".clustalw") names.append(nt_new + '.clustalw') names.append(aa_new + '.clustalw') except OSError: pass break return names
def starAndCap(st): ''' idea: read from st into new buf word by word until len of new buf >= 77, then add buf into new string with a newline and star attached ''' buf = '' newst = '' words = st.split(' ') for word in words: if len(buf) + len(word) >= 77: newst += ' * ' + buf.strip() + '\n' # kill hanging space buf = '' while len( word ) >= 77: # comes after buf clear because that needs to happen anyway if len(word) too big newst += ' * ' + word[:77] + '\n' word = word[77:] buf += word + ' ' # clear remainder of buf newst += ' * ' + buf.strip() + '\n' return newst if __name__ == '__main__': for arg in argv[1:]: mv(arg, arg + '.bak') with open(arg, 'w') as f: cls() print 'FILE', arg, '\n\n\n\n' f.write(autodoc(arg + '.bak'))
module = MODULE(board) fpid = FPID('mine') module.SetFPID(fpid) plugin.FootprintSave(lib_path2, module) # Verify that the same plugin instance can edge trigger on a lib_path change # for a FootprintSave() plugin.FootprintSave(lib_path1, module) # create a disparity between the library's name ("footprint"), # and the module's internal useless name ("mine"). Module is officially named "footprint" now # but has (module mine ...) internally: mv("%s/mine.kicad_mod" % lib_path2, "%s/footprint.kicad_mod" % lib_path2) footprint = plugin.FootprintLoad(lib_path2, 'footprint') fpid = footprint.GetFPID() fpid.SetLibNickname(UTF8('mylib')) name = fpid.Format().GetChars() # example to get the UTF8 char buffer # Always after a FootprintLoad() the internal name should match the one used to load it. print("Internal name should be 'footprint': '%s'" % name) # Verify that the same plugin instance can edge trigger on a lib_path change # for FootprintLoad() footprint = plugin.FootprintLoad(lib_path1, 'mine') fpid = footprint.GetFPID()
def trucate_video(target, start=25, end=600): import os from moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip os.mv(target, target + '_original') ffmpeg_extract_subclip(target + '_original', start, end, targetname=target)
from os import rename as mv from sys import argv if __name__ == '__main__': for arg in argv[1:]: mv(arg + '.bak', arg)
def move(self): mv(self.path, f'{self.destination}/{self.name}')
module = MODULE( board ) fpid = FPID( 'mine' ) module.SetFPID( fpid ) plugin.FootprintSave( lib_path2, module ) # Verify that the same plugin instance can edge trigger on a lib_path change # for a FootprintSave() plugin.FootprintSave( lib_path1, module ) # create a disparity between the library's name ("footprint"), # and the module's internal useless name ("mine"). Module is officially named "footprint" now # but has (module mine ...) internally: mv( "%s/mine.kicad_mod" % lib_path2, "%s/footprint.kicad_mod" % lib_path2 ) footprint = plugin.FootprintLoad( lib_path2, 'footprint' ) fpid = footprint.GetFPID() fpid.SetLibNickname( UTF8( 'mylib' ) ) name = fpid.Format().GetChars() # example to get the UTF8 char buffer # Always after a FootprintLoad() the internal name should match the one used to load it. print( "Internal name should be 'footprint': '%s'" % name ) # Verify that the same plugin instance can edge trigger on a lib_path change # for FootprintLoad() footprint = plugin.FootprintLoad( lib_path1, 'mine' ) fpid = footprint.GetFPID()