Skip to content

Commit

Permalink
Bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
rdipardo committed Mar 8, 2021
1 parent 2ce0c21 commit 231db22
Show file tree
Hide file tree
Showing 11 changed files with 90 additions and 107 deletions.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/new-issue.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ assignees: ''
*Please provide the following with your description of the issue:*
- [ ] Platform information (e.g. Ubuntu Linux 16.04):
- [ ] Python version:
- [ ] plugin version (enter `:echo g:cpywrite#version` at the vim command window):

*If applicable, include one of the following:*
- [ ] Output of `pip list | grep requests`:
Expand Down
Binary file added .github/img/vim_8.2.2549.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed .github/img/vim_821860.gif
Binary file not shown.
12 changes: 10 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
name: (Neo)vim
on: [push, pull_request]
on:
push:
tags:
- '*'
branches:
- pre-release
pull_request:
branches:
- master
jobs:
lint:
runs-on: ubuntu-20.04
Expand All @@ -10,7 +18,7 @@ jobs:
with:
python-version: '3.9'
- name: Restore cache
uses: actions/cache@v2
uses: actions/cache@v2.1.4
with:
path: '~/.cache/pip'
key: ${{ runner.os }}-pip-${{ hashFiles('.vintrc.yml') }}
Expand Down
42 changes: 0 additions & 42 deletions .travis.yml

This file was deleted.

14 changes: 14 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@ CHANGELOG
:depth: 1
:backlinks: top

0.3.3
======
**(2021-03-08)**

Fixed
-----
- (temporarily) request *ALL* full text licenses from the `previous release versions`_
(with the exception of the `Unlicense`_ and `BSD-1-Clause`_ as before). A future
release will probably start using a different repository when theses versions
fall too far behind the officially recognized templates
- minor refactoring of some redundant code

.. _previous release versions: https://github.com/spdx/license-list-data/releases/tag/v3.11

0.3.2
======
**(2020-12-28)**
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ vim-cpywrite

Generate copyright headers for any open source license

.. figure:: .github/img/vim_821860.gif
:alt: nvim-043-linux-demo
.. figure:: .github/img/vim_8.2.2549.gif
:alt: vim-win-x64-demo
:align: center
:width: 900

Expand Down
2 changes: 1 addition & 1 deletion plugin/cpywrite.vim
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
if get(g:, 'loaded_cpywrite') | finish | endif
let g:loaded_cpywrite = 1

let g:cpywrite#version = '0.3.2'
let g:cpywrite#version = '0.3.3'

if empty(get(g:, 'cpywrite#default_license', ''))
let g:cpywrite#default_license = 'GPL-3.0-or-later'
Expand Down
2 changes: 1 addition & 1 deletion rplugin/pythonx/cpywrite/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
~~~~~~~~~
"""

__version__ = '0.3.2'
__version__ = '0.3.3'
__authors__ = ['Robert Di Pardo']
__url__ = 'https://github.com/rdipardo/vim-cpywrite'
__license__ = 'MIT'
Expand Down
118 changes: 60 additions & 58 deletions rplugin/pythonx/cpywrite/spdx/license.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,36 +60,7 @@ def header(self):
pass

if license_data is None:
try:
response = requests.get(resource)

if response.status_code == 200:
try:
safe_xml = \
''.join([ch for ch in response.text if strict_ascii(ch)])
license_data = parser.fromstring(safe_xml)
_, temp_file = \
tempfile.mkstemp(prefix=self.spdx_code + '_',
suffix=".xml",
text=True)
if temp_file:
try:
with open(temp_file, 'w') as tmp:
tmp.write(safe_xml)
except IOError:
pass

except (parser.ParseError, TypeError, IOError):
print("Got invalid licence data from %s." % (resource),
file=stderr)
else:
print("Unexpected response [%d] from %s.\n"
% (response.status_code, resource),
file=stderr)

except (requests.exceptions.MissingSchema,
requests.exceptions.ConnectionError):
print("Error requesting %s." % (resource), file=stderr)
license_data = _fetch_license(resource, self.spdx_code, strict_ascii)

if license_data is None:
return ''
Expand Down Expand Up @@ -178,14 +149,17 @@ def license_text(self):
if not self.spdx_code:
return ''

text_resource = 'https://raw.githubusercontent.com/' \
'spdx/license-list-data/master/text/%s.txt'

# TODO: open an issue about these: # pylint: disable=W0511
# TODO: find a more reliable license generator: # pylint: disable=W0511
# https://github.com/spdx/license-list-data/blob/master/text/MIT.txt
# https://github.com/spdx/license-list-data/blob/master/text/0BSD.txt
# https://github.com/spdx/license-list-data/blob/2e20899c0504ff6c0acfcc1b0994d7163ce46939/text/Unlicense.txt#L10
# https://github.com/spdx/license-list-data/blob/2e20899c0504ff6c0acfcc1b0994d7163ce46939/text/BSD-1-Clause.txt#L9
if self.spdx_code == 'Unlicense' or \
self.spdx_code == 'BSD-1-Clause':
# etc., etc.
text_resource = 'https://raw.githubusercontent.com/' \
'spdx/license-list-data/' \
'2e20899c0504ff6c0acfcc1b0994d7163ce46939/text/%s.txt'

if self.spdx_code in ['Unlicense', 'BSD-1-Clause']:
text_resource = 'https://raw.githubusercontent.com/' \
'spdx/license-list-data/' \
'cade284866b0a1b6b18d7cb159279d3d41e6fa07/text/%s.txt'
Expand All @@ -202,29 +176,10 @@ def license_text(self):
pass

if license_text is None:
try:
response = requests.get(resource)

if response.status_code == 200:
license_text = response.text
_, temp_file = \
tempfile.mkstemp(prefix=self.spdx_code + '_',
suffix=".txt",
text=True)
if temp_file:
try:
with open(temp_file, 'w') as tmp:
tmp.write(license_text)
except IOError:
pass
else:
print("Unexpected response [%d] from %s.\n"
% (response.status_code, resource),
file=stderr)
license_text = _fetch_license(resource, self.spdx_code)

except (requests.exceptions.MissingSchema,
requests.exceptions.ConnectionError):
print("Error requesting %s." % (resource), file=stderr)
if license_text is None:
return ''

# - try to keep sub-clauses left-aligned;
# - try to preserve indent of copyright notice;
Expand Down Expand Up @@ -302,6 +257,53 @@ def _find_cached_license(short_name, ext='.xml'):

return None

def _fetch_license(resource, spdx_id, validator=None):
license_data = None
cached_content = None
ext = '.xml' if validator else '.txt'

try:
response = requests.get(resource)

if response.status_code == 200:
if validator:
try:
safe_xml = \
''.join([ch for ch in response.text if validator(ch)])
license_data = parser.fromstring(safe_xml)
cached_content = safe_xml
except (parser.ParseError, TypeError):
print("Got invalid licence data from %s." % (resource),
file=stderr)
else:
license_data = response.text
cached_content = license_data

try:
_, temp_file = \
tempfile.mkstemp(prefix=spdx_id + '_',
suffix=ext,
text=True)
if temp_file:
try:
with open(temp_file, 'w') as tmp:
tmp.write(cached_content)
except IOError:
pass

except IOError:
pass
else:
print("Unexpected response [%d] from %s.\n"
% (response.status_code, resource),
file=stderr)

except (requests.exceptions.MissingSchema,
requests.exceptions.ConnectionError):
print("Error requesting %s." % (resource), file=stderr)

return license_data

_SPDX_IDS = [
'0BSD',
'AAL',
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.2
0.3.3

0 comments on commit 231db22

Please sign in to comment.