How to use copyfile method in lettuce-tools

Best Python code snippet using lettuce-tools_python

clasificador.py

Source:clasificador.py Github

copy

Full Screen

...28 xml_dict = xmltodict.parse(t)29 return xml_dict30#-- --------------------------------------------------------------31def copy_file(filename, part, clasification):32 copyfile(ANNOTATIONS_FOLDER+part+filename, ANNOTATIONS_FOLDER+clasification+filename)33 copyfile(ANNOTATIONS_FOLDER_2+part+filename, ANNOTATIONS_FOLDER_2+clasification+filename)34 copyfile(DETECTIONS_FOLDER+part+'DOCODE/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE/'+filename)35 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO/lambda_1/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO/lambda_1/'+filename)36 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO/lambda_2/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO/lambda_2/'+filename)37 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO/lambda_3/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO/lambda_3/'+filename)38 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO/lambda_4/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO/lambda_4/'+filename)39 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO/lambda_5/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO/lambda_5/'+filename)40 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO/lambda_6/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO/lambda_6/'+filename)41 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO/lambda_7/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO/lambda_7/'+filename)42 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO/lambda_8/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO/lambda_8/'+filename)43 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO/lambda_9/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO/lambda_9/'+filename)44 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO/lambda_10/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO/lambda_10/'+filename)45 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO/lambda_11/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO/lambda_11/'+filename)46 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO/lambda_12/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO/lambda_12/'+filename)47 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO/lambda_13/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO/lambda_13/'+filename)48 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO/lambda_14/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO/lambda_14/'+filename)49 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO/lambda_15/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO/lambda_15/'+filename)50 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO/lambda_16/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO/lambda_16/'+filename)51 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO/lambda_17/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO/lambda_17/'+filename)52 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO/lambda_18/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO/lambda_18/'+filename)53 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO/lambda_19/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO/lambda_19/'+filename)54 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO/lambda_20/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO/lambda_20/'+filename)55 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO/lambda_21/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO/lambda_21/'+filename)56 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO/lambda_22/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO/lambda_22/'+filename)57 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO/lambda_23/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO/lambda_23/'+filename)58 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO/lambda_24/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO/lambda_24/'+filename)59 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO/lambda_25/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO/lambda_25/'+filename)60 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO/lambda_26/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO/lambda_26/'+filename)61 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO/lambda_27/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO/lambda_27/'+filename)62 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO/lambda_28/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO/lambda_28/'+filename)63 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO/lambda_29/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO/lambda_29/'+filename)64 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO/lambda_30/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO/lambda_30/'+filename)65 #DOCODE NORMALIZADO X SEGMENTO66 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO_SEGMENTO/lambda_1/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO_SEGMENTO/lambda_1/'+filename)67 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO_SEGMENTO/lambda_2/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO_SEGMENTO/lambda_2/'+filename)68 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO_SEGMENTO/lambda_3/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO_SEGMENTO/lambda_3/'+filename)69 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO_SEGMENTO/lambda_4/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO_SEGMENTO/lambda_4/'+filename)70 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO_SEGMENTO/lambda_5/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO_SEGMENTO/lambda_5/'+filename)71 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO_SEGMENTO/lambda_6/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO_SEGMENTO/lambda_6/'+filename)72 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO_SEGMENTO/lambda_7/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO_SEGMENTO/lambda_7/'+filename)73 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO_SEGMENTO/lambda_8/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO_SEGMENTO/lambda_8/'+filename)74 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO_SEGMENTO/lambda_9/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO_SEGMENTO/lambda_9/'+filename)75 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO_SEGMENTO/lambda_10/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO_SEGMENTO/lambda_10/'+filename)76 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO_SEGMENTO/lambda_11/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO_SEGMENTO/lambda_11/'+filename)77 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO_SEGMENTO/lambda_12/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO_SEGMENTO/lambda_12/'+filename)78 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO_SEGMENTO/lambda_13/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO_SEGMENTO/lambda_13/'+filename)79 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO_SEGMENTO/lambda_14/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO_SEGMENTO/lambda_14/'+filename)80 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO_SEGMENTO/lambda_15/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO_SEGMENTO/lambda_15/'+filename)81 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO_SEGMENTO/lambda_16/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO_SEGMENTO/lambda_16/'+filename)82 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO_SEGMENTO/lambda_17/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO_SEGMENTO/lambda_17/'+filename)83 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO_SEGMENTO/lambda_18/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO_SEGMENTO/lambda_18/'+filename)84 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO_SEGMENTO/lambda_19/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO_SEGMENTO/lambda_19/'+filename)85 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO_SEGMENTO/lambda_20/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO_SEGMENTO/lambda_20/'+filename)86 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO_SEGMENTO/lambda_21/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO_SEGMENTO/lambda_21/'+filename)87 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO_SEGMENTO/lambda_22/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO_SEGMENTO/lambda_22/'+filename)88 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO_SEGMENTO/lambda_23/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO_SEGMENTO/lambda_23/'+filename)89 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO_SEGMENTO/lambda_24/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO_SEGMENTO/lambda_24/'+filename)90 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO_SEGMENTO/lambda_25/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO_SEGMENTO/lambda_25/'+filename)91 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO_SEGMENTO/lambda_26/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO_SEGMENTO/lambda_26/'+filename)92 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO_SEGMENTO/lambda_27/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO_SEGMENTO/lambda_27/'+filename)93 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO_SEGMENTO/lambda_28/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO_SEGMENTO/lambda_28/'+filename)94 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO_SEGMENTO/lambda_29/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO_SEGMENTO/lambda_29/'+filename)95 copyfile(DETECTIONS_FOLDER+part+'DOCODE_NORMALIZADO_SEGMENTO/lambda_30/'+filename, DETECTIONS_FOLDER+clasification+'DOCODE_NORMALIZADO_SEGMENTO/lambda_30/'+filename)96#-- --------------------------------------------------------------97def clasificador():98 for part in PARTS:99 print SOURCES_FOLDER+part100 file_list = fileList(SOURCES_FOLDER+part, 'xml')101 files = []102 for xml_file in file_list:103 filename = xml_file.replace(SOURCES_FOLDER+part,'').replace('.xml/','')104 txt_file = xml_file.replace('xml','txt')105 words = len(open(txt_file,"r").read())106 107 plagiarism = 0108 xml_dict = xml(xml_file)109 for f in xml_dict['document']['feature'] :...

Full Screen

Full Screen

fs-copy-file.js

Source:fs-copy-file.js Github

copy

Full Screen

1'use strict';2const path = require('path');3const fs = require('fs');4const test = require('tape');5const tryToCatch = require('try-to-catch');6const {promisify} = require('util');7const {8 COPYFILE_FICLONE,9 COPYFILE_FICLONE_FORCE,10 COPYFILE_EXCL,11} = require('..').constants;12const fixture = path.join(__dirname, 'fixture');13const noop = () => {};14test('fs.copyFile: no args: message', async (t) => {15 const copyFileOriginal = fs.copyFile;16 fs.copyFile = null;17 18 const copyFile = promisify(rerequire('..'));19 const _copyFile = promisify(copyFile);20 21 const msg = 'The "callback" argument must be of type function';22 const [e] = await tryToCatch(_copyFile);23 24 fs.copyFile = copyFileOriginal;25 26 t.equal(e.message, msg, 'should throw when no callback');27 t.end();28});29test('copyFile: no args: code', async (t) => {30 const copyFileOriginal = fs.copyFile;31 fs.copyFile = null;32 33 const copyFile = promisify(rerequire('..'));34 const _copyFile = promisify(copyFile);35 36 const code = 'ERR_INVALID_CALLBACK';37 const [e] = await tryToCatch(_copyFile);38 39 fs.copyFile = copyFileOriginal;40 41 t.equal(e.code, code, 'should throw when no callback');42 t.end();43});44test('copyFile: no dest', async (t) => {45 const src = '1';46 const dest = 0;47 48 const original = fs.copyFile;49 fs.copyFile = null;50 const copyFile = rerequire('..');51 const _copyFile = promisify(copyFile);52 53 const [e] = await tryToCatch(_copyFile, src, dest);54 const msg = 'The "dest" argument must be one of type string, Buffer, or URL. Received type number';55 fs.copyFile = original;56 57 t.equal(e.message, msg, 'should throw when dest not string');58 t.end();59});60test('copyFile: no src', async (t) => {61 const src = 1;62 const dest = '0';63 64 const original = fs.copyFile;65 fs.copyFile = null;66 const copyFile = rerequire('..');67 const _copyFile = promisify(copyFile);68 69 const [e] = await tryToCatch(_copyFile, src, dest);70 const msg = 'The "src" argument must be one of type string, Buffer, or URL. Received type number';71 fs.copyFile = original;72 73 t.equal(e.message, msg, 'should throw when src not string');74 t.end();75});76test('copyFile: no src', async(t) => {77 const src = path.join(fixture, String(Math.random()));78 const dest = path.join(fixture, 'dest');79 80 const original = fs.copyFile;81 fs.copyFile = null;82 83 const copyFile = promisify(rerequire('..'));84 const [e] = await tryToCatch(copyFile, src, dest);85 86 fs.copyFile = original;87 88 t.equal(e.code, 'ENOENT', 'should not find file');89 t.end();90});91test('copyFile', async (t) => {92 const src = path.join(fixture, 'src');93 const dest = path.join(fixture, 'dest');94 95 const original = fs.copyFile;96 fs.copyFile = null;97 98 const copyFile = promisify(rerequire('..'));99 await tryToCatch(copyFile, src, dest);100 101 const data = fs.readFileSync(dest, 'utf8');102 fs.unlinkSync(dest);103 fs.copyFile = original;104 105 t.equal(data, 'hello\n', 'should copy file');106 t.end();107});108test('copyFile: original', async (t) => {109 const src = path.join(fixture, 'src');110 const dest = path.join(fixture, 'dest');111 112 const copyFile = promisify(rerequire('..'));113 await tryToCatch(copyFile, src, dest);114 115 const data = fs.readFileSync(dest, 'utf8');116 fs.unlinkSync(dest);117 118 t.equal(data, 'hello\n', 'should copy file');119 t.end();120});121test('copyFile: EEXIST', async (t) => {122 const src = path.join(fixture, 'src');123 const dest = path.join(fixture, 'dest');124 const {COPYFILE_EXCL} = fs.constants;125 126 const original = fs.copyFile;127 fs.copyFile = null;128 129 fs.writeFileSync(dest, 'hello');130 131 const copyFile = promisify(rerequire('..'));132 const [e] = await tryToCatch(copyFile, src, dest, COPYFILE_EXCL);133 134 fs.copyFile = original;135 fs.unlinkSync(dest);136 137 t.equal(e.code, 'EEXIST', 'should return error');138 t.end();139});140test('copyFile: pipe', async (t) => {141 const src = path.join(fixture, 'src');142 const dest = path.join(fixture, 'dest');143 144 const original = fs.copyFile;145 fs.copyFile = null;146 147 const copyFile = promisify(rerequire('..'));148 await tryToCatch(copyFile, src, dest, COPYFILE_EXCL);149 150 const data = fs.readFileSync(dest, 'utf8');151 fs.unlinkSync(dest);152 153 fs.copyFile = original;154 t.equal(data, 'hello\n', 'should copy file');155 t.end();156});157test('copyFile: COPYFILE_EXCL: EEXIST: pipe', async (t) => {158 const src = path.join(fixture, 'src');159 const dest = path.join(fixture, 'dest');160 161 const original = fs.copyFile;162 fs.copyFile = null;163 164 fs.writeFileSync(dest, 'hello');165 166 const copyFile = promisify(rerequire('..'));167 const [e] = await tryToCatch(copyFile, src, dest, COPYFILE_EXCL);168 169 fs.unlinkSync(dest);170 fs.copyFile = original;171 t.equal(e.code, 'EEXIST', 'should return error');172 t.end();173});174test('copyFile: COPYFILE_EXCL | COPYFILE_FICLONE : EEXIST: pipe', async (t) => {175 const src = path.join(fixture, 'src');176 const dest = path.join(fixture, 'dest');177 178 const original = fs.copyFile;179 fs.copyFile = null;180 181 fs.writeFileSync(dest, 'hello');182 183 const copyFile = promisify(rerequire('..'));184 const [e] = await tryToCatch(copyFile, src, dest, COPYFILE_EXCL | COPYFILE_FICLONE);185 186 fs.unlinkSync(dest);187 fs.copyFile = original;188 t.equal(e.code, 'EEXIST', 'should return error');189 t.end();190});191test('copyFile: COPYFILE_EXCL | COPYFILE_FICLONE_FORCE : EEXIST: pipe', async (t) => {192 const src = path.join(fixture, 'src');193 const dest = path.join(fixture, 'dest');194 195 const original = fs.copyFile;196 fs.copyFile = null;197 198 fs.writeFileSync(dest, 'hello');199 200 const copyFile = promisify(rerequire('..'));201 const [e] = await tryToCatch(copyFile, src, dest, COPYFILE_EXCL | COPYFILE_FICLONE_FORCE);202 203 fs.unlinkSync(dest);204 fs.copyFile = original;205 t.equal(e.code, 'EEXIST', 'should return error');206 t.end();207});208test('copyFile: pipe: COPYFILE_EXCL', async (t) => {209 const src = path.join(fixture, 'src');210 const dest = path.join(fixture, 'dest');211 212 const original = fs.copyFile;213 fs.copyFile = null;214 215 const copyFile = promisify(rerequire('..'));216 await tryToCatch(copyFile, src, dest, COPYFILE_EXCL);217 218 const data = fs.readFileSync(dest, 'utf8');219 fs.unlinkSync(dest);220 221 fs.copyFile = original;222 t.equal(data, 'hello\n', 'should copy file');223 t.end();224});225test('copyFile: COPYFILE_EXCL: stat: error', async (t) => {226 const src = path.join(fixture, 'src');227 const dest = path.join(fixture, 'dest');228 229 const original = fs.copyFile;230 const {stat} = fs;231 232 fs.copyFile = null;233 fs.stat = (name, cb) => cb(Error('hello'));234 235 const copyFile = promisify(rerequire('..'));236 const [e] = await tryToCatch(copyFile, src, dest, COPYFILE_EXCL);237 238 fs.copyFile = original;239 fs.stat = stat;240 241 t.equal(e.message, 'hello', 'should return stat error');242 t.end();243});244test('copyFile: bad flags: more', (t) => {245 const src = '1';246 const dest = '2';247 248 const original = fs.copyFile;249 fs.copyFile = null;250 251 const copyFile = rerequire('..');252 253 const fn = () => copyFile(src, dest, 8, noop);254 255 fs.copyFile = original;256 t.throws(fn, /EINVAL: invalid argument, copyfile -> '2'/, 'should throw');257 t.end();258});259test('copyFile: bad flags: less', (t) => {260 const src = '1';261 const dest = '2';262 263 const original = fs.copyFile;264 fs.copyFile = null;265 266 const copyFile = rerequire('..');267 268 const fn = () => copyFile(src, dest, -1, noop);269 270 fs.copyFile = original;271 t.throws(fn, /EINVAL: invalid argument, copyfile -> '2'/, 'should throw');272 t.end();273});274function rerequire(name) {275 delete require.cache[require.resolve(name)];276 return require(name);...

Full Screen

Full Screen

mgfinder_old.py

Source:mgfinder_old.py Github

copy

Full Screen

...23 try:24 #print(mgtable['ZABS'][j])25 if mgtable['ZABS'][j] >= 0.37 and mgtable['ZABS'][j] < 0.55:26 print(mgtable['ZABS'][j])27 #copyfile('/data/marvels/jerryxu/dr7/catalog/' + str(mgtable['INDEX_QSO'][j] + 1) + '-g.fit', '/data/marvels/billzhu/MG II Dataset/0.37 - 0.55/' + str(mgtable['INDEX_QSO'][j] + 1) + '-g.fit')28 for k in range(1, 105784):29 temp = linecache.getline('Full Data.txt', k).split()30 #print(k)31 if abs(float(temp[1]) - mgtable['RA'][j]) < 0.0001 and abs(float(temp[2]) - mgtable['DEC'][j]) < 0.0001:32 print(k)33 copyfile('/data/marvels/jerryxu/dr7/raw_catalog/' + str(k) + '.fit', '/data/marvels/billzhu/MG II Obj/0.37 - 0.55/' + str(k) + '.fit')34 copyfile('/data/marvels/jerryxu/dr7/catalog/' + str(k) + '-g.fit', '/data/marvels/billzhu/MG II Dataset/0.37 - 0.55/g/' + str(k) + '-g.fit')35 copyfile('/data/marvels/jerryxu/dr7/catalog/' + str(k) + '-r.fit', '/data/marvels/billzhu/MG II Dataset/0.37 - 0.55/r/' + str(k) + '-r.fit')36 copyfile('/data/marvels/jerryxu/dr7/catalog/' + str(k) + '-i.fit', '/data/marvels/billzhu/MG II Dataset/0.37 - 0.55/i/' + str(k) + '-i.fit')37 #copyfile('/data/marvels/jerryxu/dr7/catalog/' + str(i) + '-u.fit', '/data/marvels/billzhu/MG II Dataset/0.37 - 0.55/' + str(i) + '-u.fit')38 copyfile('/data/marvels/jerryxu/dr7/catalog/' + str(k) + '-z.fit', '/data/marvels/billzhu/MG II Dataset/0.37 - 0.55/z/' + str(k) + '-z.fit')39 break40 41 """42 if mgtable['ZABS'][j][0] >= 0.55 and mgtable['ZABS'][j][0] < 0.76:43 for k in range(1, 105784):44 temp = linecache.getline('Full Data.txt', k).split()45 #print(k)46 if abs(float(temp[1]) - mgtable['RA'][j]) < 0.001:47 print(k)48 copyfile('/data/marvels/jerryxu/dr7/catalog/' + str(k) + '-g.fit', '/data/marvels/billzhu/MG II Dataset/0.55 - 0.76/g/' + str(k) + '-g.fit')49 copyfile('/data/marvels/jerryxu/dr7/catalog/' + str(k) + '-r.fit', '/data/marvels/billzhu/MG II Dataset/0.55 - 0.76/r/' + str(k) + '-r.fit')50 copyfile('/data/marvels/jerryxu/dr7/catalog/' + str(k) + '-i.fit', '/data/marvels/billzhu/MG II Dataset/0.55 - 0.76/i/' + str(k) + '-i.fit')51 #copyfile('/data/marvels/jerryxu/dr7/catalog/' + str(i) + '-u.fit', '/data/marvels/billzhu/MG II Dataset/0.55 - 0.76/' + str(i) + '-u.fit')52 copyfile('/data/marvels/jerryxu/dr7/catalog/' + str(k) + '-z.fit', '/data/marvels/billzhu/MG II Dataset/0.55 - 0.76/z/' + str(k) + '-z.fit')53 copyfile('/data/marvels/jerryxu/dr7/raw_catalog/' + str(k) + '.fit', '/data/marvels/billzhu/MG II Obj/0.55 - 0.76/' + str(k) + '.fit')54 break55 if mgtable['ZABS'][j][0] >= 0.76 and mgtable['ZABS'][j][0] < 1.00:56 for k in range(1, 105784):57 temp = linecache.getline('Full Data.txt', k).split()58 #print(k)59 #print(temp)60 #print(mgtable['RA'][j])61 if abs(float(temp[1]) - mgtable['RA'][j]) < 0.001:62 print(k)63 copyfile('/data/marvels/jerryxu/dr7/catalog/' + str(k) + '-g.fit', '/data/marvels/billzhu/MG II Dataset/0.76 - 1.00/g/' + str(k) + '-g.fit')64 copyfile('/data/marvels/jerryxu/dr7/catalog/' + str(k) + '-r.fit', '/data/marvels/billzhu/MG II Dataset/0.76 - 1.00/r/' + str(k) + '-r.fit')65 copyfile('/data/marvels/jerryxu/dr7/catalog/' + str(k) + '-i.fit', '/data/marvels/billzhu/MG II Dataset/0.76 - 1.00/i/' + str(k) + '-i.fit')66 #copyfile('/data/marvels/jerryxu/dr7/catalog/' + str(i) + '-u.fit', '/data/marvels/billzhu/MG II Dataset/0.76 - 1.00/' + str(i) + '-u.fit')67 copyfile('/data/marvels/jerryxu/dr7/catalog/' + str(k) + '-z.fit', '/data/marvels/billzhu/MG II Dataset/0.76 - 1.00/z/' + str(k) + '-z.fit')68 copyfile('/data/marvels/jerryxu/dr7/raw_catalog/' + str(k) + '.fit', '/data/marvels/billzhu/MG II Obj/0.76 - 1.00/' + str(k) + '.fit')69 break70 """71 72 except:73 return74if __name__ == '__main__':75 #multiprocessing.set_start_method('spawn')76 #f = fits.open('QSObased_Trimmed_SDSS_DR7_107.fits')77 mgtable = Table.read('Trimmed_SDSS_DR7_107.fits', hdu=1)78 reader = open('Full Data.txt', 'r')79 count = 080 81 82 #try:...

Full Screen

Full Screen

test-fs-copyfile.js

Source:test-fs-copyfile.js Github

copy

Full Screen

1// Flags: --expose-internals2'use strict';3const common = require('../common');4const fixtures = require('../common/fixtures');5const tmpdir = require('../common/tmpdir');6const assert = require('assert');7const fs = require('fs');8const { internalBinding } = require('internal/test/binding');9const {10 UV_ENOENT,11 UV_EEXIST12} = internalBinding('uv');13const path = require('path');14const src = fixtures.path('a.js');15const dest = path.join(tmpdir.path, 'copyfile.out');16const {17 COPYFILE_EXCL,18 COPYFILE_FICLONE,19 COPYFILE_FICLONE_FORCE,20 UV_FS_COPYFILE_EXCL,21 UV_FS_COPYFILE_FICLONE,22 UV_FS_COPYFILE_FICLONE_FORCE23} = fs.constants;24function verify(src, dest) {25 const srcData = fs.readFileSync(src, 'utf8');26 const srcStat = fs.statSync(src);27 const destData = fs.readFileSync(dest, 'utf8');28 const destStat = fs.statSync(dest);29 assert.strictEqual(srcData, destData);30 assert.strictEqual(srcStat.mode, destStat.mode);31 assert.strictEqual(srcStat.size, destStat.size);32}33tmpdir.refresh();34// Verify that flags are defined.35assert.strictEqual(typeof COPYFILE_EXCL, 'number');36assert.strictEqual(typeof COPYFILE_FICLONE, 'number');37assert.strictEqual(typeof COPYFILE_FICLONE_FORCE, 'number');38assert.strictEqual(typeof UV_FS_COPYFILE_EXCL, 'number');39assert.strictEqual(typeof UV_FS_COPYFILE_FICLONE, 'number');40assert.strictEqual(typeof UV_FS_COPYFILE_FICLONE_FORCE, 'number');41assert.strictEqual(COPYFILE_EXCL, UV_FS_COPYFILE_EXCL);42assert.strictEqual(COPYFILE_FICLONE, UV_FS_COPYFILE_FICLONE);43assert.strictEqual(COPYFILE_FICLONE_FORCE, UV_FS_COPYFILE_FICLONE_FORCE);44// Verify that files are overwritten when no flags are provided.45fs.writeFileSync(dest, '', 'utf8');46const result = fs.copyFileSync(src, dest);47assert.strictEqual(result, undefined);48verify(src, dest);49// Verify that files are overwritten with default flags.50fs.copyFileSync(src, dest, 0);51verify(src, dest);52// Verify that UV_FS_COPYFILE_FICLONE can be used.53fs.unlinkSync(dest);54fs.copyFileSync(src, dest, UV_FS_COPYFILE_FICLONE);55verify(src, dest);56// Verify that COPYFILE_FICLONE_FORCE can be used.57try {58 fs.unlinkSync(dest);59 fs.copyFileSync(src, dest, COPYFILE_FICLONE_FORCE);60 verify(src, dest);61} catch (err) {62 assert.strictEqual(err.syscall, 'copyfile');63 assert(err.code === 'ENOTSUP' || err.code === 'ENOTTY' ||64 err.code === 'ENOSYS' || err.code === 'EXDEV');65 assert.strictEqual(err.path, src);66 assert.strictEqual(err.dest, dest);67}68// Copies asynchronously.69tmpdir.refresh(); // Don't use unlinkSync() since the last test may fail.70fs.copyFile(src, dest, common.mustCall((err) => {71 assert.ifError(err);72 verify(src, dest);73 // Copy asynchronously with flags.74 fs.copyFile(src, dest, COPYFILE_EXCL, common.mustCall((err) => {75 if (err.code === 'ENOENT') { // Could be ENOENT or EEXIST76 assert.strictEqual(err.message,77 'ENOENT: no such file or directory, copyfile ' +78 `'${src}' -> '${dest}'`);79 assert.strictEqual(err.errno, UV_ENOENT);80 assert.strictEqual(err.code, 'ENOENT');81 assert.strictEqual(err.syscall, 'copyfile');82 } else {83 assert.strictEqual(err.message,84 'EEXIST: file already exists, copyfile ' +85 `'${src}' -> '${dest}'`);86 assert.strictEqual(err.errno, UV_EEXIST);87 assert.strictEqual(err.code, 'EEXIST');88 assert.strictEqual(err.syscall, 'copyfile');89 }90 }));91}));92// Throws if callback is not a function.93assert.throws(() => {94 fs.copyFile(src, dest, 0, 0);95}, {96 code: 'ERR_INVALID_CALLBACK',97 name: 'TypeError'98});99// Throws if the source path is not a string.100[false, 1, {}, [], null, undefined].forEach((i) => {101 assert.throws(102 () => fs.copyFile(i, dest, common.mustNotCall()),103 {104 code: 'ERR_INVALID_ARG_TYPE',105 name: 'TypeError',106 message: /src/107 }108 );109 assert.throws(110 () => fs.copyFile(src, i, common.mustNotCall()),111 {112 code: 'ERR_INVALID_ARG_TYPE',113 name: 'TypeError',114 message: /dest/115 }116 );117 assert.throws(118 () => fs.copyFileSync(i, dest),119 {120 code: 'ERR_INVALID_ARG_TYPE',121 name: 'TypeError',122 message: /src/123 }124 );125 assert.throws(126 () => fs.copyFileSync(src, i),127 {128 code: 'ERR_INVALID_ARG_TYPE',129 name: 'TypeError',130 message: /dest/131 }132 );133});134assert.throws(() => {135 fs.copyFileSync(src, dest, 'r');136}, {137 code: 'ERR_INVALID_ARG_TYPE',138 name: 'TypeError',139 message: /mode/140});141assert.throws(() => {142 fs.copyFileSync(src, dest, 8);143}, {144 code: 'ERR_OUT_OF_RANGE',145 name: 'RangeError',146 message: 'The value of "mode" is out of range. It must be an integer ' +147 '>= 0 && <= 7. Received 8'148});149assert.throws(() => {150 fs.copyFile(src, dest, 'r', common.mustNotCall());151}, {152 code: 'ERR_INVALID_ARG_TYPE',153 name: 'TypeError',154 message: /mode/...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run lettuce-tools automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful