def get(self, cpe): """ convert 3 to 2 Converts a CPE code to the CPE2.2 standard, stripped of appendices. CPE2.2 is the old standard, and is a lot less uniform than the CPE2.3 standard. """ cpe = toOldCPE(cpe) if cpe is False: return api.abort( 400, "Conversion failed, the CPE code you provided cannot be converted" ) else: return cpe
def cpe22(cpe): cpe = toOldCPE(cpe) if not cpe: cpe='None' return cpe
def cpe22(cpe): cpe = toOldCPE(cpe) if not cpe: cpe = 'None' return cpe
def cpe22(cpe): cpe = toOldCPE(cpe) if not cpe: cpe = "None" return cpe
def api_cpe22(self, cpe): cpe = toOldCPE(cpe) return cpe, 200 if cpe else "None", 404
'in': ['a', 'b', 'c', 'd', 'e', 'f'], 'expect': ['a', 'b', 'c', 'd', 'e', 'f'] }] result = [] for x in extend: result.append( resultOf(x['in'], toStringFormattedCPE(x['in'], autofill=True), x['expect'])) printResults('Translate to 2.3 - success/autofill', result) result = [] for x in trans: result.append(resultOf(x['in'], toStringFormattedCPE(x['in']), x['expect'])) printResults('Translate to 2.3 - success/no autofill', result) result = [] for x in old: result.append(resultOf(x['in'], toOldCPE(x['in']), x['expect'])) printResults('Translate to 2.2 - success/no autofill', result) result = [] for x in pad1: result.append(resultOf(x['in'], pad(x['in'], 5), x['expect'])) for x in padtext1: result.append(resultOf(x['in'], pad(x['in'], 5, '-'), x['expect'])) for x in padtext2: result.append(resultOf(x['in'], pad(x['in'], 5, 'text'), x['expect'])) printResults('Padding lists - empty, char and text - ', result)
{'in':['a','b','c','d','e'], 'expect':['a','b','c','d','e']}, {'in':['a','b','c','d','e','f'], 'expect':['a','b','c','d','e','f']}] padtext2=[{'in':['a','b','c'], 'expect':['a','b','c','text','text']}, {'in':['a','b','c','d','e'], 'expect':['a','b','c','d','e']}, {'in':['a','b','c','d','e','f'], 'expect':['a','b','c','d','e','f']}] result=[] for x in extend: result.append(resultOf(x['in'],toStringFormattedCPE(x['in'],autofill=True),x['expect'])) printResults('Translate to 2.3 - success/autofill',result) result=[] for x in trans: result.append(resultOf(x['in'],toStringFormattedCPE(x['in']),x['expect'])) printResults('Translate to 2.3 - success/no autofill',result) result=[] for x in old: result.append(resultOf(x['in'],toOldCPE(x['in']),x['expect'])) printResults('Translate to 2.2 - success/no autofill',result) result=[] for x in pad1: result.append(resultOf(x['in'],pad(x['in'],5),x['expect'])) for x in padtext1: result.append(resultOf(x['in'],pad(x['in'],5,'-'),x['expect'])) for x in padtext2: result.append(resultOf(x['in'],pad(x['in'],5,'text'),x['expect'])) printResults('Padding lists - empty, char and text - ',result)
] padtext2 = [ {"in": ["a", "b", "c"], "expect": ["a", "b", "c", "text", "text"]}, {"in": ["a", "b", "c", "d", "e"], "expect": ["a", "b", "c", "d", "e"]}, {"in": ["a", "b", "c", "d", "e", "f"], "expect": ["a", "b", "c", "d", "e", "f"]}, ] result = [] for x in extend: result.append(resultOf(x["in"], toStringFormattedCPE(x["in"], autofill=True), x["expect"])) printResults("Translate to 2.3 - success/autofill", result) result = [] for x in trans: result.append(resultOf(x["in"], toStringFormattedCPE(x["in"]), x["expect"])) printResults("Translate to 2.3 - success/no autofill", result) result = [] for x in old: result.append(resultOf(x["in"], toOldCPE(x["in"]), x["expect"])) printResults("Translate to 2.2 - success/no autofill", result) result = [] for x in pad1: result.append(resultOf(x["in"], pad(x["in"], 5), x["expect"])) for x in padtext1: result.append(resultOf(x["in"], pad(x["in"], 5, "-"), x["expect"])) for x in padtext2: result.append(resultOf(x["in"], pad(x["in"], 5, "text"), x["expect"])) printResults("Padding lists - empty, char and text - ", result)