Skip to content

Commit 2507806

Browse files
committed
Merge master into release/3
--HG-- branch : release
2 parents aed1a0d + 2cb1cd6 commit 2507806

File tree

14 files changed

+304
-40
lines changed

14 files changed

+304
-40
lines changed

.github/FUNDING.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# FUNDING.yml - GitHub sponsor button configuration
2+
# Copyright (C) 2019 Kaz Nishimura
3+
#
4+
# Copying and distribution of this file, with or without modification, are
5+
# permitted in any medium without royalty provided the copyright notice and
6+
# this notice are preserved. This file is offered as-is, without any warranty.
7+
---
8+
custom:
9+
- https://salt.bountysource.com/checkout/amount?team=vx68k

.hgtags

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
6db5290c92e4890dcea7a32d33be1da8ef41b0d1 release/1.0b3
22
1fe0824b4525a8e45ec313a041081a267a2660f8 release/1.0b4
33
53d49c8c44d12ce03e6c0555d629eb0dc39b6dc5 release/1.0
4+
3e7041ecfc2e21611c649abff920bc755f6231cc release/2.0

.vscode/settings.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,10 @@
77
"**/*.rej": true,
88
"**/*.orig": true,
99
"**/*~": true
10-
}
10+
},
11+
"python.testing.unittestEnabled": true,
12+
"python.testing.unittestArgs": [
13+
"-s",
14+
"test"
15+
]
1116
}

.vscode/tasks.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
"command": "${config:python.pythonPath}",
88
"args": [
99
"./setup.py",
10-
"test"
10+
"build"
1111
],
12-
"group": "build"
12+
"group": "build",
13+
"problemMatcher": []
1314
},
1415
{
1516
"label": "Rebuild",
@@ -18,9 +19,10 @@
1819
"args": [
1920
"./setup.py",
2021
"clean",
21-
"test"
22+
"build"
2223
],
23-
"group": "build"
24+
"group": "build",
25+
"problemMatcher": []
2426
},
2527
{
2628
"label": "Clean",

MANIFEST.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
include README.md
1+
include test/prepare.py
2+
include test/*.b64

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Introduction
22

3-
The `prcslib` package provides a <dfn>Python API for PRCS</dfn>.
3+
The [`prcslib` package][prcslib] provides a <dfn>Python API for PRCS</dfn>.
44

55
[PRCS][] (Project Revision Control System) is a legacy version control system
66
that manages a *project* consisting of multiple files
@@ -9,6 +9,7 @@ and records related changes across them as a unit.
99
See the [home page][] for more information about the `prcslib` package.
1010

1111
[home page]: https://vx68k.bitbucket.io/prcslib.py/
12+
[prcslib]: https://pypi.org/project/prcslib/
1213
[PRCS]: http://prcs.sourceforge.net/
1314

1415
[![(Chat)](https://img.shields.io/gitter/room/vx68k/prcslib.py.svg)][Gitter room]

azure-pipelines.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,23 @@ stages:
1414
jobs:
1515
- job: Build
1616
pool:
17-
vmImage: ubuntu-latest
17+
vmImage: ubuntu-16.04
18+
container: kazssym/python-prcs:3
1819
steps:
19-
- task: UsePythonVersion@0
2020
- bash: |
2121
pip install \
2222
"setuptools>=38.6" \
23-
wheel \
24-
tox
23+
unittest-xml-reporting \
24+
wheel
2525
displayName: Install dependencies
2626
- bash: |
27-
tox
27+
python test/prepare.py test/testproject.prcs.b64
28+
python -m xmlrunner discover -s test -o test-reports
2829
displayName: Test
30+
env:
31+
PRCS_REPOSITORY: /tmp/PRCS
2932
- task: PublishTestResults@2
33+
condition: succeededOrFailed()
3034
- bash: |
3135
python ./setup.py sdist bdist_wheel
3236
displayName: Create archives

prcslib/__init__.py

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
# Matching pattern for info records.
4444
_INFO_RECORD_PATTERN = \
45-
re.compile(br"^([^ ]+) ([^ ]+) (.+) by ([^ ]+) ?(\*DELETED\*)?")
45+
re.compile(r"^([^ ]+) ([^ ]+) (.+) by ([^ ]+) ?(\*DELETED\*)?")
4646

4747
class PrcsError(Exception):
4848
"""base exception class for the prcslib package
@@ -58,12 +58,16 @@ def __init__(self, error_message):
5858

5959
class PrcsVersion:
6060
"""
61-
version identifier on PRCS
61+
Version identifier on PRCS
62+
63+
A version identifier on PRCS is composed of major and minor parts separated
64+
by a full stop (U+002E). The former is a string, and the latter is a
65+
positive integral number.
6266
"""
6367

6468
def __init__(self, major, minor=None):
6569
"""
66-
construct a version identifier
70+
Construct a version identifier
6771
"""
6872
if isinstance(major, PrcsVersion):
6973
if minor is None:
@@ -81,13 +85,13 @@ def __str__(self):
8185

8286
def major(self):
8387
"""
84-
major part of the version identifier
88+
Return the major part of the version identifier as a 'str' value
8589
"""
8690
return self._major
8791

8892
def minor(self):
8993
"""
90-
minor part of the version identifier
94+
Return the minor part of the version identifier as an 'int' value
9195
"""
9296
return self._minor
9397

@@ -101,27 +105,27 @@ def __init__(self, name):
101105
self.name = name
102106

103107
def versions(self):
104-
"""return a dictionary of the summary records for all the versions
108+
"""
109+
return a dictionary of the summary records for all the versions
105110
"""
106111
out, err, status = self._run_prcs(["info", "-f", self.name])
112+
if status != 0:
113+
raise PrcsCommandError(err.decode())
107114

108115
versions = {}
109-
if not err:
110-
# We use iteration over lines so that we can detect parse errors.
111-
for line in out.splitlines():
112-
match = _INFO_RECORD_PATTERN.match(line)
113-
if match:
114-
# Note: the 'prcs info' command returns local times.
115-
project, version, date, author, deleted = match.groups()
116-
versions[version.decode()] = {
117-
"project": project.decode(),
118-
"id": version.decode(),
119-
"date": datetime(*parsedate(date.decode())[0:6]),
120-
"author": author.decode(),
121-
"deleted": bool(deleted),
122-
}
123-
else:
124-
raise PrcsCommandError(err)
116+
# We use iteration over lines so that we can detect parse errors.
117+
for line in out.splitlines():
118+
match = _INFO_RECORD_PATTERN.match(line.decode())
119+
if match:
120+
# Note: the 'prcs info' command returns local times.
121+
project, version, date, author, deleted = match.groups()
122+
versions[version] = {
123+
"project": project,
124+
"id": version,
125+
"date": datetime(*parsedate(date)[0:6]),
126+
"author": author,
127+
"deleted": bool(deleted),
128+
}
125129
return versions
126130

127131
def descriptor(self, version=None):
@@ -142,8 +146,8 @@ def checkout(self, version=None, files=None):
142146
args.append(self.name)
143147
args.extend(files)
144148
__, err, status = self._run_prcs(args)
145-
if err:
146-
sys.stderr.write(err)
149+
if status != 0:
150+
raise PrcsCommandError(err.decode())
147151

148152
def _run_prcs(self, args=None, stdin=None):
149153
"""

setup.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,11 @@
2929
from os import path
3030
from setuptools import setup, find_packages
3131

32+
# Package name.
33+
PACKAGE_NAME = "prcslib"
34+
3235
# Package version.
33-
PACKAGE_VERSION = "2.0"
36+
PACKAGE_VERSION = "3.0"
3437

3538
def long_description():
3639
"""
@@ -47,10 +50,14 @@ def long_description():
4750

4851
if __name__ == "__main__":
4952
setup(
50-
name="prcslib",
53+
name=PACKAGE_NAME,
5154
version=PACKAGE_VERSION,
5255
description="Python API for PRCS.",
5356
url="https://vx68k.bitbucket.io/prcslib.py/",
57+
project_urls={
58+
# Libraries.io will pick the 'Source' location for the repository.
59+
"Source": "https://github.com/vx68k/prcslib.py",
60+
},
5461
author="Kaz Nishimura",
5562
author_email="kazssym@linuxfront.com",
5663
long_description=long_description(),
@@ -67,6 +74,6 @@ def long_description():
6774
python_requires=">=2.7",
6875
zip_safe=True,
6976

70-
packages=find_packages(exclude=["testsuite", "testsuite.*"]),
77+
packages=find_packages(exclude=["test", "test.*"]),
7178
test_suite="testsuite",
7279
)
File renamed without changes.

test/prepare.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# prepare.py
2+
# Copyright (C) 2020 Kaz Nishimura
3+
#
4+
# Permission is hereby granted, free of charge, to any person obtaining a copy
5+
# of this software and associated documentation files (the "Software"), to
6+
# deal in the Software without restriction, including without limitation the
7+
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8+
# sell copies of the Software, and to permit persons to whom the Software is
9+
# furnished to do so, subject to the following conditions:
10+
#
11+
# The above copyright notice and this permission notice shall be included in
12+
# all copies or substantial portions of the Software.
13+
#
14+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20+
# IN THE SOFTWARE.
21+
#
22+
# SPDX-License-Identifier: MIT
23+
24+
"""
25+
prepare a PRCS project for tests
26+
"""
27+
28+
from __future__ import absolute_import
29+
import sys
30+
import os
31+
32+
def main():
33+
"""
34+
Prepare a PRCS project by extracting from a package
35+
"""
36+
package = sys.argv[1]
37+
return os.system("base64 -d '%s' | prcs unpackage -f -" % package)
38+
39+
if __name__ == "__main__":
40+
sys.exit(main() != 0)
File renamed without changes.

0 commit comments

Comments
 (0)