Skip to content

Commit d2b37a1

Browse files
Modify PackageManifest class names and attributes
Modifies PackageManifest class names to be camelcase and deletes attribute `manifest_type` from individual classes. Signed-off-by: Ayan Sinha Mahapatra <ayansmahapatra@gmail.com>
1 parent b8968e2 commit d2b37a1

37 files changed

Lines changed: 407 additions & 427 deletions

src/packagedcode/__init__.py

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
# Note: the order matters: from the most to the least specific
4040
# Package classes MUST be added to this list to be active
4141
PACKAGE_MANIFEST_TYPES = [
42-
rpm.RPMManifest,
42+
rpm.RpmManifest,
4343
debian.DebianPackage,
4444

4545
models.JavaJar,
@@ -51,38 +51,38 @@
5151
models.Axis2Mar,
5252

5353
about.Aboutfile,
54-
npm.NPMPackageJSON,
55-
npm.NPMPackageLockJSON,
56-
npm.NPMYarnLockJSON,
57-
phpcomposer.PHPComposerJSON,
58-
phpcomposer.PHPComposerLock,
59-
haxe.HaxelibJSON,
60-
cargo.RustCargoToml,
61-
cargo.RustCargoLock,
62-
cocoapods.CocoapodsPodspec,
63-
cocoapods.CocoapodsPodfileLock,
64-
cocoapods.CocoapodsPodspecJSON,
54+
npm.PackageJson,
55+
npm.PackageLockJson,
56+
npm.YarnLockJson,
57+
phpcomposer.ComposerJson,
58+
phpcomposer.ComposerLock,
59+
haxe.HaxelibJson,
60+
cargo.CargoToml,
61+
cargo.CargoLock,
62+
cocoapods.Podspec,
63+
cocoapods.PodfileLock,
64+
cocoapods.PodspecJson,
6565
opam.OpamFile,
6666
models.MeteorPackage,
67-
bower.BowerJSON,
68-
freebsd.FreeBSDCompactManifest,
67+
bower.BowerJson,
68+
freebsd.CompactManifest,
6969
models.CpanModule,
70-
rubygems.RubyGemArchive,
71-
rubygems.RubyGemArchiveExtracted,
72-
rubygems.RubyGemSpec,
73-
rubygems.RubyGemfileLock,
70+
rubygems.GemArchive,
71+
rubygems.GemArchiveExtracted,
72+
rubygems.GemSpec,
73+
rubygems.GemfileLock,
7474
models.AndroidApp,
7575
models.AndroidLibrary,
7676
models.MozillaExtension,
7777
models.ChromeExtension,
7878
models.IOSApp,
79-
pypi.PythonMetadataFile,
80-
pypi.PythonBinaryDist,
81-
pypi.PythonSourceDist,
82-
pypi.PythonSetupPy,
83-
pypi.PythonDependencyFile,
84-
pypi.PythonPipfileLock,
85-
pypi.PythonRequirementsFile,
79+
pypi.MetadataFile,
80+
pypi.BinaryDistArchive,
81+
pypi.SourceDistArchive,
82+
pypi.SetupPy,
83+
pypi.DependencyFile,
84+
pypi.PipfileLock,
85+
pypi.RequirementsFile,
8686
golang.GoMod,
8787
golang.GoSum,
8888
models.CabPackage,
@@ -93,7 +93,7 @@
9393
models.AppleDmgPackage,
9494
models.IsoImagePackage,
9595
models.SquashfsPackage,
96-
chef.MetadataJSON,
96+
chef.MetadataJson,
9797
chef.Metadatarb,
9898
build.BazelPackage,
9999
build.BuckPackage,
@@ -104,7 +104,7 @@
104104
build.MetadataBzl,
105105
msi.MsiInstallerPackage,
106106
windows.MicrosoftUpdateManifest,
107-
pubspec.PubspecYAML,
107+
pubspec.PubspecYaml,
108108
pubspec.PubspecLock
109109
]
110110

src/packagedcode/about.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,13 @@ class Aboutfile(AboutPackage, models.PackageManifest):
4848

4949
file_patterns = ('*.ABOUT',)
5050
extensions = ('.ABOUT',)
51-
manifest_type = 'aboutfile'
5251

5352
@classmethod
5453
def is_manifest(cls, location):
5554
"""
5655
Return True if the file at ``location`` is likely a manifest of this type.
5756
"""
58-
return (filetype.is_file(location) and location.lower().endswith(('.about',)))
57+
return filetype.is_file(location) and location.lower().endswith(('.about',))
5958

6059
@classmethod
6160
def recognize(cls, location):

src/packagedcode/bower.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,10 @@ def compute_normalized_license(self):
4343

4444

4545
@attr.s()
46-
class BowerJSON(BowerPackage, models.PackageManifest):
46+
class BowerJson(BowerPackage, models.PackageManifest):
4747

4848
file_patterns = ('bower.json', '.bower.json')
4949
extensions = ('.json',)
50-
manifest_type = 'bowerjson'
5150

5251
@classmethod
5352
def is_manifest(cls, location):

src/packagedcode/cargo.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535

3636
@attr.s()
3737
class RustCargoCrate(models.Package):
38-
file_patterns = ('Cargo.toml', 'Cargo.lock')
3938
default_type = 'cargo'
4039
default_primary_language = 'Rust'
4140
default_web_baseurl = 'https://crates.io'
@@ -60,19 +59,17 @@ def api_data_url(self, baseurl=default_api_baseurl):
6059

6160

6261
@attr.s()
63-
class RustCargoToml(RustCargoCrate, models.PackageManifest):
62+
class CargoToml(RustCargoCrate, models.PackageManifest):
6463

6564
file_patterns = ('Cargo.toml',)
66-
extensions = ('.json',)
67-
manifest_type = 'cargotoml'
65+
extensions = ('.toml',)
6866

6967
@classmethod
7068
def is_manifest(cls, location):
7169
"""
7270
Return True if the file at ``location`` is likely a manifest of this type.
7371
"""
74-
return (filetype.is_file(location)
75-
and fileutils.file_name(location).lower() == 'cargo.toml')
72+
return filetype.is_file(location) and fileutils.file_name(location).lower() == 'cargo.toml'
7673

7774
@classmethod
7875
def recognize(cls, location):
@@ -106,11 +103,10 @@ def recognize(cls, location):
106103

107104

108105
@attr.s()
109-
class RustCargoLock(RustCargoCrate, models.PackageManifest):
106+
class CargoLock(RustCargoCrate, models.PackageManifest):
110107

111108
file_patterns = ('Cargo.lock',)
112109
extensions = ('.lock',)
113-
manifest_type = 'cargolock'
114110

115111
@classmethod
116112
def is_manifest(cls, location):

src/packagedcode/chef.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,10 @@ def format(self, tokens, outfile):
156156

157157

158158
@attr.s()
159-
class MetadataJSON(ChefPackage, models.PackageManifest):
159+
class MetadataJson(ChefPackage, models.PackageManifest):
160160

161161
file_patterns = ('metadata.json',)
162162
extensions = ('.json',)
163-
manifest_type = 'metadatajson'
164163

165164
@classmethod
166165
def is_manifest(cls, location):
@@ -192,7 +191,6 @@ class Metadatarb(ChefPackage, models.PackageManifest):
192191

193192
file_patterns = ('metadata.rb',)
194193
extensions = ('.rb',)
195-
manifest_type = 'metadatarb'
196194

197195
@classmethod
198196
def is_manifest(cls, location):

src/packagedcode/cocoapods.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444

4545
@attr.s()
46-
class BaseCocoapodsPackage(models.Package):
46+
class CocoapodsPackage(models.Package):
4747
default_type = 'pods'
4848
default_primary_language = 'Objective-C'
4949
default_web_baseurl = 'https://cocoapods.org'
@@ -117,18 +117,17 @@ def get_podname_proper(podname):
117117

118118

119119
@attr.s()
120-
class CocoapodsPodspec(BaseCocoapodsPackage, models.PackageManifest):
120+
class Podspec(CocoapodsPackage, models.PackageManifest):
121121

122122
file_patterns = ('*.podspec',)
123123
extensions = ('.podspec',)
124-
manifest_type = 'podspec'
125124

126125
@classmethod
127126
def is_manifest(cls, location):
128127
"""
129128
Return True if the file at ``location`` is likely a manifest of this type.
130129
"""
131-
return (filetype.is_file(location) and location.endswith('.podspec'))
130+
return filetype.is_file(location) and location.endswith('.podspec')
132131

133132
@classmethod
134133
def recognize(cls, location):
@@ -177,11 +176,10 @@ def recognize(cls, location):
177176

178177

179178
@attr.s()
180-
class CocoapodsPodfileLock(BaseCocoapodsPackage, models.PackageManifest):
179+
class PodfileLock(CocoapodsPackage, models.PackageManifest):
181180

182181
file_patterns = ('*podfile.lock',)
183182
extensions = ('.lock',)
184-
manifest_type = 'podfilelock'
185183

186184
@classmethod
187185
def is_manifest(cls, location):
@@ -264,18 +262,17 @@ def read_podfile_lock(location):
264262

265263

266264
@attr.s()
267-
class CocoapodsPodspecJSON(BaseCocoapodsPackage, models.PackageManifest):
265+
class PodspecJson(CocoapodsPackage, models.PackageManifest):
268266

269267
file_patterns = ('*.podspec.json',)
270268
extensions = ('.json',)
271-
manifest_type = 'podspecjson'
272269

273270
@classmethod
274271
def is_manifest(cls, location):
275272
"""
276273
Return True if the file at ``location`` is likely a manifest of this type.
277274
"""
278-
return (filetype.is_file(location) and location.endswith('.podspec.json'))
275+
return filetype.is_file(location) and location.endswith('.podspec.json')
279276

280277
@classmethod
281278
def recognize(cls, location):

src/packagedcode/conda.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ class Condayml(CondaPackage, models.PackageManifest):
7777

7878
file_patterns = ('meta.yaml', 'META.yml',)
7979
extensions = ('.yml', '.yaml',)
80-
manifest_type = 'condayml'
8180

8281
@classmethod
8382
def is_manifest(cls, location):

src/packagedcode/freebsd.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,9 @@ def compute_normalized_license(self):
4747

4848

4949
@attr.s()
50-
class FreeBSDCompactManifest(FreeBSDPackage, models.PackageManifest):
50+
class CompactManifest(FreeBSDPackage, models.PackageManifest):
5151

5252
file_patterns = ('+COMPACT_MANIFEST',)
53-
manifest_type = 'compactmanifest'
5453

5554
@classmethod
5655
def is_manifest(cls, location):

src/packagedcode/golang.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,14 @@ class GoMod(GolangPackage, models.PackageManifest):
5656

5757
file_patterns = ('go.mod',)
5858
extensions = ('.mod',)
59-
manifest_type = 'gomod'
6059

6160
@classmethod
6261
def is_manifest(cls, location):
6362
"""
6463
Return True if the file at ``location`` is likely a manifest of this type.
6564
"""
6665
filename = fileutils.file_name(location).lower()
67-
return (filetype.is_file(location) and filename == 'go.mod')
66+
return filetype.is_file(location) and filename == 'go.mod'
6867

6968
@classmethod
7069
def recognize(cls, location):
@@ -120,15 +119,14 @@ class GoSum(GolangPackage, models.PackageManifest):
120119

121120
file_patterns = ('go.sum',)
122121
extensions = ('.sum',)
123-
manifest_type = 'gosum'
124122

125123
@classmethod
126124
def is_manifest(cls, location):
127125
"""
128126
Return True if the file at ``location`` is likely a manifest of this type.
129127
"""
130128
filename = fileutils.file_name(location).lower()
131-
return (filetype.is_file(location) and filename == 'go.sum')
129+
return filetype.is_file(location) and filename == 'go.sum'
132130

133131
@classmethod
134132
def recognize(cls, location):

src/packagedcode/haxe.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,17 @@ def repository_download_url(self, baseurl=default_download_baseurl):
6969

7070

7171
@attr.s()
72-
class HaxelibJSON(HaxePackage, models.PackageManifest):
72+
class HaxelibJson(HaxePackage, models.PackageManifest):
7373

7474
file_patterns = ('haxelib.json',)
7575
extensions = ('.json',)
76-
manifest_type = 'haxlibjson'
7776

7877
@classmethod
7978
def is_manifest(cls, location):
8079
"""
8180
Return True if the file at ``location`` is likely a manifest of this type.
8281
"""
83-
return (filetype.is_file(location)
84-
and fileutils.file_name(location).lower() == 'haxelib.json')
82+
return filetype.is_file(location) and fileutils.file_name(location).lower() == 'haxelib.json'
8583

8684
@classmethod
8785
def recognize(cls, location):

0 commit comments

Comments
 (0)