def test_testName(self): color.blue("test here baby") fileContent = """sqlCopyOrgs = require '../1.org/sqlCopyOrgs.iced' module.exports = (autocb)-> """ result = callForSyncFunc.isItSync(fileContent) expected = False assertMy.equals(result, expected)
def test_testName(self): color.blue("test here baby") fileContent = """cityListInCountryId = require '../../city/filter/byCountryForCitiesWithoutRegion/cityListInCountryId.iced' module.exports = (countryId, regionId, autocb)-> # first try get cities by countryId:""" result = callForSyncFunc.isItSync(fileContent) expected = False assertMy.equals(result, expected)
def test_testName(self): color.blue("test here baby") fileContent = """require 'colors' module.exports = (str1, str2)-> outStr1 = "" outStr2 = """ result = callForSyncFunc.isItSync(fileContent) expected = True assertMy.equals(result, expected)
def do(targeFilename, sourceFilename): target = targeFilename source = sourceFilename print("target:", target, "-----------------------------------------------------") print("source:", source, "-----------------------------------------------------") rel = absRel.RelAndCutIfNodeModules(source, target) # 1) get fileName by filePath filename = absRel.filename(target) # 2) create string: #{fileName} = require '#{relativePath}' require = "{0} = require '{1}'".format(filename, rel) # 3) set to cliboard objectName - filename # 3.1) get param names: # get fileContent_target to load it once: fileContent_target = filer2.read(target) # check if function sync: sync = callForSyncFunc.isItSync(fileContent_target) color.red("sync in relativeRequireIced_model.py") print(sync) isCbWithouAutocb = callForSyncFunc.isItCb(fileContent_target) color.red("isCbWithouAutocb in relativeRequireIced_model.py") print(isCbWithouAutocb) if isCbWithouAutocb: # (...,cb)-> params = getParams.getParamsCb(fileContent_target) ending = returnLast.getReturnParamsForAutocbCommaSeparated(fileContent_target) toClip = "await {0}{1} defer {2}".format(filename, params, ending) else: if sync: # load params sync params = callForSyncFunc.byFileContent(fileContent_target) returnParams = returnLast.returnParamsForSyncExpressionOrReturn(fileContent_target) toClip = "{2} = {0}{1}".format(filename, params, returnParams) else: # async: (..., autocb)-> params = getParams.getParamsAutocb(fileContent_target) autocbOneEnding = returnLast.autocbOneEnding(fileContent_target) if autocbOneEnding: toClip = "await {0}{1} defer {2}".format(filename, params, autocbOneEnding) else: ending = returnLast.doAllByFileName(target) toClip = "await {0}{1} defer result{2}".format(filename, params, ending) result = (require, toClip) return result