forked from aboutcode-org/scancode-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwindows.py
More file actions
60 lines (50 loc) · 1.92 KB
/
windows.py
File metadata and controls
60 lines (50 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#
# Copyright (c) nexB Inc. and others. All rights reserved.
# ScanCode is a trademark of nexB Inc.
# SPDX-License-Identifier: Apache-2.0
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
# See https://github.com/nexB/scancode-toolkit for support or download.
# See https://aboutcode.org for more information about nexB OSS projects.
#
import xmltodict
from packagedcode import models
class MicrosoftUpdateManifestHandler(models.NonAssemblableDatafileHandler):
datasource_id = 'microsoft_update_manifest_mum'
path_patterns = ('*.mum',)
filetypes = ('xml 1.0 document',)
default_package_type = 'windows-update'
description = 'Microsoft Update Manifest .mum file'
@classmethod
def parse(cls, location, package_only=False):
with open(location , 'rb') as loc:
parsed = xmltodict.parse(loc)
if not parsed:
return
assembly = parsed.get('assembly', {})
description = assembly.get('@description', '')
company = assembly.get('@company', '')
copyrght = assembly.get('@copyright', '')
support_url = assembly.get('@supportInformation', '')
assembly_identity = assembly.get('assemblyIdentity', {})
name = assembly_identity.get('@name', '')
version = assembly_identity.get('@version', '')
parties = []
if company:
parties.append(
models.Party(
name=company,
type=models.party_org,
role='owner',
)
)
package_data = dict(
datasource_id=cls.datasource_id,
type=cls.default_package_type,
name=name,
version=version,
description=description,
homepage_url=support_url,
parties=parties,
copyright=copyrght,
)
yield models.PackageData.from_data(package_data, package_only)