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
def test_testName(self): color.blue("test here baby") targetFileContent = """globalLinkForAdminDeleteCommentBy_id = require 'orad/model/globalLinkForAdminDeleteCommentBy_id.iced' th = require 'throw' orgLinkUrlByOrgId = require 'monvgo/model/org/orgLinkUrlByOrgId.iced' makeLinkUrlGlobal = require '../../links/makeLinkUrlGlobal.iced' module.exports = (comment)-> globalLink = globalLinkForAdminDeleteCommentBy_id comment._id orgUrlLink = orgLinkUrlByOrgId comment.OrgId globalOrgiBizLinkUrl = makeLinkUrlGlobal orgUrlLink msgForEmail = comment.Info + "\ndelete: #{globalOrgiBizLinkUrl}" """ result = returnLast.returnParamsForSyncExpressionOrReturn(targetFileContent) expected = "msgForEmail" assertMy.equals(result, expected)