MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / js_map_sources_lines

Function js_map_sources_lines

src/textcode/analysis.py:223–247  ·  view source on GitHub ↗

Yield unicode text lines from the js.map or css.map file at `location`. Spec is at: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit The format is: { "version" : 3, "file": "out.js", "sourceRoot": "",

(location)

Source from the content-addressed store, hash-verified

221
222
223def js_map_sources_lines(location):
224 """
225 Yield unicode text lines from the js.map or css.map file at `location`.
226 Spec is at:
227 https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit
228 The format is:
229 {
230 "version" : 3,
231 "file": "out.js",
232 "sourceRoot": "",
233 "sources": ["foo.js", "bar.js"],
234 "sourcesContent": [null, null],
235 "names": ["src", "maps", "are", "fun"],
236 "mappings": "A,AAAB;;ABCDE;"
237 }
238 We care only about the presence of these tags for detection: version, sources, sourcesContent.
239 """
240 with io.open(location, encoding='utf-8') as jsm:
241 content = json.load(jsm)
242 sources = content.get('sourcesContent', [])
243 for entry in sources:
244 entry = replace_verbatim_cr_lf_chars(entry)
245 for line in entry.splitlines():
246 l = remove_verbatim_cr_lf_tab_chars(line)
247 yield l
248
249
250def as_unicode(line):

Callers 1

numbered_text_linesFunction · 0.85

Calls 5

getMethod · 0.65
openMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected