Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ python:
- "2.6"
- "2.7"
install: "pip install -r requirements.txt --use-mirrors"
script: python tests.py
script: python setup.py test
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ http://www.dejacode.org/about_spec_v0.8.0.html

REQUIREMENTS
------------
The ABOUT tool has been tested with Python 2.6 or 2.7 on Linux, Mac and Windows.
The ABOUT tool is tested with Python 2.6 or 2.7 on Linux, Mac and Windows.
You will need to install a Python interpreter if you do not have one already
installed.

Expand Down Expand Up @@ -63,7 +63,7 @@ https://github.com/dejacode/about-code-tool/archive/master.zip

Then open a terminal or command prompt, extract the download if needed and run::

python tests.py
python setup.py test


USAGE
Expand Down
9 changes: 4 additions & 5 deletions about.ABOUT
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
about_resource: .
about_resource: about-code-tool/about.py

name: ABOUT tool
version: 0.8.1
Expand All @@ -14,9 +14,9 @@ changelog_file: CHANGELOG.txt
vcs_tool: git
vcs_repository: https://github.com/dejacode/about-code-tool.git

description: This is a tool to process ABOUT files. An ABOUT file provides a
simple way to document the provenance (origin and license) 'about' a software
component. An ABOUT file is a small text file stored in the codebase
description: This is a tool to process ABOUT files. An ABOUT file provides a
simple way to document the provenance (origin and license) 'about' a software
component. An ABOUT file is a small text file stored in the codebase
side-by-side with the software component that it documents.


Expand All @@ -35,4 +35,3 @@ notice:
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.

File renamed without changes.
12 changes: 12 additions & 0 deletions about_code_tool/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# =============================================================================
# Copyright (c) 2013 by nexB, Inc. http://www.nexb.com/ - All rights reserved.
# 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.
# =============================================================================
18 changes: 9 additions & 9 deletions about.py → about_code_tool/about.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ def license_text(self):
license_text_path = self.file_fields_locations["license_text_file"]
with open(license_text_path, 'rU') as f:
return f.read()
except Exception as e:
except Exception as e:
pass
#return empty string if the license file does not exist
return ""
Expand All @@ -567,7 +567,7 @@ def notice_text(self):
notice_text_path = self.file_fields_locations["notice_file"]
with open(notice_text_path, 'rU') as f:
return f.read()
except Exception as e:
except Exception as e:
pass
#return empty string if the notice file does not exist
return ""
Expand Down Expand Up @@ -1015,21 +1015,21 @@ def generate_attribution(self, template_path='templates/default.html',
return

# We only need the fields names and values to render the template
about_validated_fields = [about_object.validated_fields
for about_object in self.about_objects
if not sublist
about_validated_fields = [about_object.validated_fields
for about_object in self.about_objects
if not sublist
or about_object.about_resource_path in sublist]

about_license_text = [about_object.license_text()
for about_object in self.about_objects
if not sublist
about_license_text = [about_object.license_text()
for about_object in self.about_objects
if not sublist
or about_object.about_resource_path in sublist]
about_notice_text = [about_object.notice_text()
for about_object in self.about_objects
if not sublist
or about_object.about_resource_path in sublist]

return template.render(about_objects = about_validated_fields,
return template.render(about_objects = about_validated_fields,
license_texts = about_license_text,
notice_texts = about_notice_text)

Expand Down
55 changes: 22 additions & 33 deletions genabout.py → about_code_tool/genabout.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@
Warn = namedtuple('Warn', 'field_name field_value message',)
Error = namedtuple('Error', 'field_name field_value message',)

self_path = abspath(dirname(__file__))


class GenAbout(object):

def __init__(self):
self.warnings = []
self.errors = []
Expand Down Expand Up @@ -93,7 +95,6 @@ def read_input(self, input_file, mapping):
components_list.append(file_list)
return components_list


@staticmethod
def config_mapping(mapping):
about_resource = 'about_resource'
Expand All @@ -102,7 +103,7 @@ def config_mapping(mapping):
version = 'version'
if mapping:
try:
with open('MAPPING.CONFIG', "rU") as file_in:
with open(join(self_path, 'MAPPING.CONFIG'), "rU") as file_in:
for line in file_in.readlines():
if not line.startswith('#'):
if line.partition(':')[0] == 'about_resource':
Expand All @@ -129,7 +130,6 @@ def config_mapping(mapping):
else:
return about_resource, about_file, name, version


def verify_license_files(self, input_list, project_path):
"""
Verify the existence of the 'license text file'
Expand Down Expand Up @@ -162,7 +162,6 @@ def verify_license_files(self, input_list, project_path):
sys.exit(errno.EINVAL)
return output_list


def copy_license_files(self, gen_location, license_list):
"""
copy the 'license_text_file' into the gen_location
Expand All @@ -177,14 +176,11 @@ def copy_license_files(self, gen_location, license_list):
makedirs(license_parent_dir)
shutil.copy2(license_path, output_license_path)

"""
def extract_licesen_from_url(self):
# This function needs discussion
test = urllib2.urlopen("https://enterprise.dejacode.com/license_library/Demo/gpl-1.0/#license-text")
with open('testdata/test_file.txt', 'wb') as output_file:
output_file.write(test.read())
"""

#def extract_license_from_url(self):
# # This function needs discussion
# test = urllib2.urlopen("https://enterprise.dejacode.com/license_library/Demo/gpl-1.0/#license-text")
# with open('testdata/test_file.txt', 'wb') as output_file:
# output_file.write(test.read())

def pre_generation(self, gen_location, input_list, action_num, all_in_one):
"""
Expand Down Expand Up @@ -234,28 +230,22 @@ def pre_generation(self, gen_location, input_list, action_num, all_in_one):
output_list.append(component_list)
return output_list


def format_output(self, input_list):
@staticmethod
def format_output(input_list):
"""
process the input and covert to the specific strings format
Process the input and convert to the specific strings format.
"""
components_list = []
for items in input_list:
for entry in input_list:
about_file_location = entry[0]
about_dict_list = entry[1]

component = []
about_file_location = items[0]
about_dict_list = items[1]
context = ''
if about_dict_list['name']:
name = about_dict_list['name']
else:
name = ''
if about_dict_list['version']:
version = about_dict_list['version']
else:
version = ''
context = 'about_resource: ' + about_dict_list['about_resource'] + '\n' \
+ 'name: ' + name + '\n' \
+ 'version: ' + version + '\n\n'
component_name = about_dict_list.get('name', '')
component_version = about_dict_list.get('version', '')
context = 'about_resource: %s\nname: %s\nversion: %s\n\n' % (
about_dict_list['about_resource'], component_name, component_version)

for item in sorted(about_dict_list.iterkeys()):
if item == 'about_file':
continue
Expand All @@ -265,12 +255,12 @@ def format_output(self, input_list):
value = about_dict_list[item].replace('\n', '\n ')
if (value or item in MANDATORY_FIELDS) and not item in SKIPPED_FIELDS:
context += item + ': ' + value + '\n'

component.append(about_file_location)
component.append(context)
components_list.append(component)
return components_list


def write_output(self, output):
for line in output:
about_file_location = line[0]
Expand All @@ -280,7 +270,6 @@ def write_output(self, output):
with open(about_file_location, 'wb') as output_file:
output_file.write(context)


def warnings_errors_summary(self, gen_location, show_error_num):
display_error = False
display_warning = False
Expand Down
File renamed without changes.
File renamed without changes.
12 changes: 12 additions & 0 deletions about_code_tool/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# =============================================================================
# Copyright (c) 2013 by nexB, Inc. http://www.nexb.com/ - All rights reserved.
# 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.
# =============================================================================
Loading