-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from toabctl/improv3
Remove bitdeli image from README
- Loading branch information
Showing
8 changed files
with
323 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright (c) 2016, Thomas Bechtold <tbechtold@suse.com> | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
# implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
|
||
# The file contains a distutils command to print metadata to the console | ||
# or write it to a file. | ||
|
||
|
||
from distutils.core import Command | ||
import json | ||
|
||
|
||
class get_metadata(Command): | ||
"""a distutils command to get metadata""" | ||
description = "get package metadata" | ||
user_options = [ | ||
("output=", "o", "output for metadata json") | ||
] | ||
|
||
def initialize_options(self): | ||
self.output = None | ||
|
||
def finalize_options(self): | ||
pass | ||
|
||
def run(self): | ||
data = {} | ||
if self.distribution.has_ext_modules(): | ||
data["is_extension"] = True | ||
if getattr(self.distribution, "scripts"): | ||
data["scripts"] = self.distribution.scripts | ||
if getattr(self.distribution, "test_suite"): | ||
data["test_suite"] = self.distribution.test_suite | ||
if getattr(self.distribution, "install_requires"): | ||
data["install_requires"] = self.distribution.install_requires | ||
if getattr(self.distribution, "extras_require"): | ||
data["extras_require"] = self.distribution.extras_require | ||
if getattr(self.distribution, "tests_require"): | ||
data["tests_require"] = self.distribution.tests_require | ||
if getattr(self.distribution, "data_files"): | ||
data["data_files"] = self.distribution.data_files | ||
if getattr(self.distribution, "entry_points"): | ||
data["entry_points"] = self.distribution.entry_points | ||
|
||
if self.output: | ||
with open(self.output, "w+") as f: | ||
f.write(json.dumps(data, indent=2)) | ||
else: | ||
print(json.dumps(data, indent=2)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright (c) 2016, Thomas Bechtold <tbechtold@suse.com> | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
# implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from contextlib import contextmanager | ||
import os | ||
import shutil | ||
import tarfile | ||
import tempfile | ||
import zipfile | ||
|
||
|
||
@contextmanager | ||
def _extract_to_tempdir(filename): | ||
"""extract the given filename to a tempdir and change the cwd to the | ||
new tempdir""" | ||
tempdir = tempfile.mkdtemp(prefix="py2pack_") | ||
current_cwd = os.getcwd() | ||
names = [] | ||
try: | ||
if tarfile.is_tarfile(filename): | ||
with tarfile.open(filename) as f: | ||
names = f.getnames() | ||
f.extractall(tempdir) | ||
elif zipfile.is_zipfile(filename): | ||
with zipfile.ZipFile(filename) as f: | ||
names = f.namelist() | ||
f.extractall(tempdir) | ||
else: | ||
raise Exception("Can not extract '%s'. Not a tar or zip file" % filename) | ||
os.chdir(tempdir) | ||
yield tempdir, names | ||
finally: | ||
os.chdir(current_cwd) | ||
shutil.rmtree(tempdir) |
Oops, something went wrong.