Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

Commit d029f39

Browse files
juangallostraxispa
authored andcommitted
Pre-release fixes and corrections (#41)
* Update code headers * Include file to update code headers * Change default src dir * Change copyright from senaite.core to senaite.sync * Add Contributors file and script to generate it * Fix typo * Fix typo * Correct source directory * Hook write code headers and contributors to local buildout
1 parent fa4be51 commit d029f39

22 files changed

+298
-16
lines changed

CONTRIBUTORS.rst

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Contributors
2+
============
3+
4+
This file is autogenerated each time a release is published.
5+
6+
Contributions to master, excluding merge commits, sorted by number of
7+
contributions descending.
8+
9+
- Nihad Mammadli, [email protected]
10+
- Juan Gallostra, [email protected]
11+
- Ramon Bartl, [email protected]
12+
- Jordi Puiggené, [email protected]

README.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Installation
1616

1717
In order to get SENAITE.SYNC running properly both :code:`senaite.api` and :code:`senaite.jsonapi` are required in the source and destination instances. However, :code:`senaite.sync` is only required in the destination instance (where the data is to be imported).
1818

19-
To install SENAITE SYNC, you simply have to add :code:`senaite.sync` into the :code:`eggs` section
19+
To install SENAITE.SYNC, you simply have to add :code:`senaite.sync` into the :code:`eggs` section
2020
of your :code:`buildout.cfg`::
2121

2222
eggs =
@@ -27,7 +27,7 @@ of your :code:`buildout.cfg`::
2727
Importing data
2828
==============
2929

30-
Once SEANITE SYNC has been installed and the instance is up and running navigate to SENAITE SYNC's view by adding :code:`/sync` after the base url of the instance.
30+
Once SEANITE.SYNC has been installed and the instance is up and running navigate to SENAITE SYNC's view by adding :code:`/sync` after the base url of the instance.
3131

3232
The migration process mainly consists of three steps.
3333

@@ -62,7 +62,7 @@ Feedback and support
6262
License
6363
=======
6464

65-
SENAITE.CORE
65+
SENAITE.SYNC
6666
Copyright (C) 2018 Senaite Foundation
6767

6868
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation.

buildout.cfg

+14
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ parts =
33
instance
44
lxml
55
test
6+
write_code_headers
7+
write_contributors
68
robot
79
code-analysis
810
coverage
@@ -68,6 +70,18 @@ eggs =
6870
senaite.sync [test]
6971
defaults = ['--auto-color', '--auto-progress']
7072

73+
[write_code_headers]
74+
recipe = collective.recipe.template
75+
output = ${buildout:directory}/bin/write_code_headers
76+
input = ${buildout:directory}/templates/write_code_headers.py.in
77+
mode = 755
78+
79+
[write_contributors]
80+
recipe = collective.recipe.template
81+
output = ${buildout:directory}/bin/write_contributors
82+
input = ${buildout:directory}/templates/write_contributors.py.in
83+
mode = 755
84+
7185
[code-analysis]
7286
recipe = plone.recipe.codeanalysis
7387
directory = ${buildout:directory}/src/senaite/api

src/senaite/__init__.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# -*- coding: utf-8 -*-
22
#
3-
# Copyright 2017 SENAITE
3+
# This file is part of SENAITE.SYNC
4+
#
5+
# Copyright 2018 by it's authors.
6+
# Some rights reserved. See LICENSE.rst, CONTRIBUTORS.rst.
47

58
try:
69
__import__('pkg_resources').declare_namespace(__name__)

src/senaite/sync/__init__.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# -*- coding: utf-8 -*-
22
#
3-
# Copyright 2017 SENAITE
3+
# This file is part of SENAITE.SYNC
4+
#
5+
# Copyright 2018 by it's authors.
6+
# Some rights reserved. See LICENSE.rst, CONTRIBUTORS.rst.
47

58
import logging
69

src/senaite/sync/browser/__init__.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
# -*- coding: utf-8 -*-
22
#
3-
# Copyright 2017 SENAITE
3+
# This file is part of SENAITE.SYNC
4+
#
5+
# Copyright 2018 by it's authors.
6+
# Some rights reserved. See LICENSE.rst, CONTRIBUTORS.rst.

src/senaite/sync/browser/autosync.py

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# This file is part of SENAITE.SYNC
4+
#
5+
# Copyright 2018 by it's authors.
6+
# Some rights reserved. See LICENSE.rst, CONTRIBUTORS.rst.
17

28
from Products.Five import BrowserView
39
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile

src/senaite/sync/browser/interfaces.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# -*- coding: utf-8 -*-
22
#
3-
# Copyright 2017-2017 SENAITE LIMS.
3+
# This file is part of SENAITE.SYNC
4+
#
5+
# Copyright 2018 by it's authors.
6+
# Some rights reserved. See LICENSE.rst, CONTRIBUTORS.rst.
47

58
from zope.interface import Interface
69

src/senaite/sync/browser/views.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# -*- coding: utf-8 -*-
22
#
3-
# Copyright 2017-2017 SENAITE LIMS.
3+
# This file is part of SENAITE.SYNC
4+
#
5+
# Copyright 2018 by it's authors.
6+
# Some rights reserved. See LICENSE.rst, CONTRIBUTORS.rst.
47

58
from DateTime import DateTime
69
from BTrees.OOBTree import OOBTree

src/senaite/sync/complementstep.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# -*- coding: utf-8 -*-
22
#
3-
# Copyright 2017-2018 SENAITE SYNC.
3+
# This file is part of SENAITE.SYNC
4+
#
5+
# Copyright 2018 by it's authors.
6+
# Some rights reserved. See LICENSE.rst, CONTRIBUTORS.rst.
47

58
from datetime import datetime
69
from DateTime import DateTime

src/senaite/sync/config.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# -*- coding: utf-8 -*-
22
#
3-
# This file is part of SENAITE.LIMS
3+
# This file is part of SENAITE.SYNC
44
#
55
# Copyright 2018 by it's authors.
6-
# Some rights reserved. See LICENSE and CONTRIBUTING.
6+
# Some rights reserved. See LICENSE.rst, CONTRIBUTORS.rst.
77

88
PROJECTNAME = "senaite.sync"

src/senaite/sync/fetchstep.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# -*- coding: utf-8 -*-
22
#
3-
# Copyright 2017-2018 SENAITE SYNC.
3+
# This file is part of SENAITE.SYNC
4+
#
5+
# Copyright 2018 by it's authors.
6+
# Some rights reserved. See LICENSE.rst, CONTRIBUTORS.rst.
47

58
import transaction
69

src/senaite/sync/fieldmanagers.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# -*- coding: utf-8 -*-
22
#
3-
# Copyright 2017-2017 SENAITE LIMS.
3+
# This file is part of SENAITE.SYNC
4+
#
5+
# Copyright 2018 by it's authors.
6+
# Some rights reserved. See LICENSE.rst, CONTRIBUTORS.rst.
47

58
from zope import interface
69

src/senaite/sync/importstep.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# -*- coding: utf-8 -*-
22
#
3-
# Copyright 2017-2018 SENAITE SYNC.
3+
# This file is part of SENAITE.SYNC
4+
#
5+
# Copyright 2018 by it's authors.
6+
# Some rights reserved. See LICENSE.rst, CONTRIBUTORS.rst.
47

58
import requests
69
import transaction

src/senaite/sync/souphandler.py

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# This file is part of SENAITE.SYNC
4+
#
5+
# Copyright 2018 by it's authors.
6+
# Some rights reserved. See LICENSE.rst, CONTRIBUTORS.rst.
17

28
from senaite import api
39
from senaite.sync import logger

src/senaite/sync/syncerror.py

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# This file is part of SENAITE.SYNC
4+
#
5+
# Copyright 2018 by it's authors.
6+
# Some rights reserved. See LICENSE.rst, CONTRIBUTORS.rst.
7+
18
from zope.globalrequest import getRequest
29

310

src/senaite/sync/syncstep.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# -*- coding: utf-8 -*-
22
#
3-
# Copyright 2017-2018 SENAITE SYNC.
3+
# This file is part of SENAITE.SYNC
4+
#
5+
# Copyright 2018 by it's authors.
6+
# Some rights reserved. See LICENSE.rst, CONTRIBUTORS.rst.
47

58
import urllib
69
import urlparse

src/senaite/sync/upgrade/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
# This file is part of SENAITE.SYNC
44
#
55
# Copyright 2018 by it's authors.
6-
# Some rights reserved. See LICENSE.rst.
6+
# Some rights reserved. See LICENSE.rst, CONTRIBUTORS.rst.

src/senaite/sync/upgrade/v01_00_000.py

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# This file is part of SENAITE.SYNC
44
#
55
# Copyright 2018 by it's authors.
6+
# Some rights reserved. See LICENSE.rst, CONTRIBUTORS.rst.
67

78
from Acquisition import aq_inner
89
from Acquisition import aq_parent

src/senaite/sync/utils.py

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# This file is part of SENAITE.SYNC
4+
#
5+
# Copyright 2018 by it's authors.
6+
# Some rights reserved. See LICENSE.rst, CONTRIBUTORS.rst.
17

28
from datetime import datetime
39

templates/write_code_headers.py.in

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#!/usr/bin/env python
2+
#
3+
# Scans a source tree for python files and writes the header template on top of each file
4+
5+
import os
6+
import sys
7+
import optparse
8+
from datetime import datetime
9+
10+
SRC_DIR = '${buildout:directory}/src/senaite/sync'
11+
12+
YEAR_FROM = '2018'
13+
TEMPLATE = """# -*- coding: utf-8 -*-
14+
#
15+
# This file is part of SENAITE.SYNC
16+
#
17+
# Copyright {copy_years} by it's authors.
18+
# Some rights reserved. See LICENSE.rst, CONTRIBUTORS.rst.
19+
20+
"""
21+
22+
23+
def get_template():
24+
copy_years = datetime.now().strftime("%Y")
25+
if copy_years != YEAR_FROM:
26+
copy_years = '{}-{}'.format(YEAR_FROM, copy_years)
27+
template_data = {
28+
"copy_years": copy_years,
29+
}
30+
return TEMPLATE.format(**template_data)
31+
32+
33+
if __name__ == "__main__":
34+
35+
parser = optparse.OptionParser()
36+
37+
parser.add_option('-d', '--directory',
38+
dest='directory',
39+
default=SRC_DIR,
40+
help='Source code directory to scan [default: %default]')
41+
42+
parser.add_option('-e', '--extensions',
43+
dest='extensions',
44+
default='.py',
45+
help='Comma separated list of file extensions [default: %default]')
46+
47+
options, args = parser.parse_args(sys.argv)
48+
49+
data = {}
50+
directory = options.directory
51+
extensions = map(lambda ext: ext.strip(), options.extensions.split(","))
52+
53+
def callback(arg, dirname, names):
54+
# only write the header to the files where the file extension match (.py per default)
55+
file_names = filter(lambda x: os.path.splitext(x)[-1] in extensions, names)
56+
# generate a list of full file paths
57+
file_paths = map(lambda x: os.path.abspath(os.path.join(dirname, x)), file_names)
58+
# make a mapping of path -> file data
59+
for path in file_paths:
60+
lines = open(path, "r").readlines()
61+
data[path] = lines
62+
63+
# walk the directory
64+
os.path.walk(directory, callback, None)
65+
66+
for path, lines in data.iteritems():
67+
# the new lines start with our header
68+
new_lines = [get_template()]
69+
70+
skip = True
71+
for num, line in enumerate(lines):
72+
# skip all commented lines, but not those of Script (Python)
73+
if skip and line.startswith("#") and not line.startswith("##"):
74+
continue
75+
# skip app empty lines
76+
if skip and line == "\n":
77+
continue
78+
79+
# if we reach this point, we found the first code line
80+
if skip:
81+
print "Found first code line for file {} at {}".format(path, num)
82+
skip = False
83+
84+
# append all code lines below the new_lines
85+
new_lines.append(line)
86+
87+
with open(path, "w") as f:
88+
# get the last line
89+
last_line = new_lines[-1]
90+
# remove all trailing empty lines and add a single one
91+
new_lines[-1] = last_line.rstrip("\n") + "\n"
92+
f.writelines(new_lines)
93+
print "Wrote header to {}".format(path)

0 commit comments

Comments
 (0)