Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stderr fix #1606

Merged
merged 19 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,21 @@ As of v3.0.0 this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased][develop]
### Fixed
- Multiple Scribus render frames were all using the same file name, which would result in the same score appearing in all render frames. This change makes the score files use an available Scribus variable to force multiple file names.
- When kpsewhich cannot write to a particular location, it generates an error which is directed to stderr but not to our glog file. This created an undocumented error when trying to write to a gtex file to a bad location. We now capture stderr output produced when compiling scores and redirect it to our glog file so that the error is properly recorded. Fixes [#1541](https://github.com/gregorio-project/gregorio/issues/1541).
- Fixed the interaction between hyphens and styles. See [#1538](https://github.com/gregorio-project/gregorio/issues/1538).
- Fixed the loss of ongoing styles when a syllable starts with a forced center. See [#1551](https://github.com/gregorio-project/gregorio/issues/1551).
- Fixed first syllables of one letter with a style causing a segfault. See [#1585](https://github.com/gregorio-project/gregorio/issues/1585).

### Changed
- Modified gregorio to append to the log file specified as an argument and to send early messages to it. See [#1541](https://github.com/gregorio-project/gregorio/issues/1541).
- Defined an output directory for gtex and glog files. Default is `tmp-gre`. This can be changed using `\gresetoutputdir{...}`. Fixes [#1393](https://github.com/gregorio-project/gregorio/issues/1393), [#1542](https://github.com/gregorio-project/gregorio/issues/1542), and [#1571](https://github.com/gregorio-project/gregorio/issues/1571).

### Added
- Added a configurable setting `\gresetunisonbreakbehavior` to control automatic line breaks between unison notes above a syllable. Defaults to `breakable` for backwards compatibility, but may be set to `unbreakable` if that behavior is desired. See [#1504](https://github.com/gregorio-project/gregorio/issues/1504).
- Added the ability to fuse upwards to a virga. See [#1558](https://github.com/gregorio-project/gregorio/issues/1558)
- Added the ability to use the "stroke" form of a clivis instead of the default two-notes form by specifying `[shape:stroke]` after the clivis to change. See [#1558](https://github.com/gregorio-project/gregorio/issues/1558)

## [Unreleased][CTAN]


## [6.0.0] - 2021-03-13
### Fixed
Expand Down
54 changes: 32 additions & 22 deletions VersionManager.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/env python2
#! /usr/bin/env python3

"""
A script that manages the VERSION of gregorio.
Expand All @@ -23,7 +23,6 @@
along with Gregorio. If not, see <http://www.gnu.org/licenses/>.
"""

from __future__ import print_function

import sys
import re
Expand All @@ -35,8 +34,6 @@
import linecache
from datetime import date

from distutils.util import strtobool

locale.setlocale(locale.LC_TIME, 'C')

os.chdir(sys.path[0])
Expand Down Expand Up @@ -170,6 +167,19 @@
"windows/uninstall.lua",
]

def strtobool(val):
"""Convert a string representation of truth to true (1) or false (0).
True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if
'val' is anything else.
"""
val = val.lower()
if val in ('y', 'yes', 't', 'true', 'on', '1'):
return 1
if val in ('n', 'no', 'f', 'false', 'off', '0'):
return 0
raise ValueError(f'invalid truth value: {val}')

def get_parser():
"Return command line parser"
parser = argparse.ArgumentParser(
Expand Down Expand Up @@ -218,7 +228,7 @@ def get_parser():
dest='release')
return parser

class Version(object):
class Version():
"Class for version manipulation."

def __init__(self, versionfile):
Expand Down Expand Up @@ -259,19 +269,17 @@ def fetch_version_debian_git(self):
['git', 'rev-parse', '--short', 'HEAD'])
self.short_tag = self.short_tag.strip('\n')
self.date = time.strftime("%Y%m%d%H%M%S")
print("{0}+git{1}+{2}".format(self.version.replace('-', '~'),
self.date, self.short_tag))
print(f"{self.version.replace('-', '~')}+git{self.date}+{self.short_tag}")
sys.exit(0)

def update_version(self, newversion):
"Update self.version and .gregorio-version with the new version."
self.version = newversion
self.filename_version = self.filename_version_from_version(newversion)
self.binary_version = self.binary_version_from_version(newversion)
print('Updating {0} with the new version: {1}\n'.format(
self.versionfile, self.version))
with open(self.versionfile, 'w') as verfile:
verfile.write('{0}\n{1}'.format(self.version, CURRENTYEAR))
print(f'Updating {self.versionfile} with the new version: {self.version}\n')
with open(self.versionfile, 'w', encoding='utf-8') as verfile:
verfile.write(f'{self.version}\n{CURRENTYEAR}')
verfile.write('\n\n*** Do not modify this file. ***\n')
verfile.write('Use VersionManager.py to change the version.\n')

Expand All @@ -281,11 +289,11 @@ def replace_version(version_obj):
newver_filename = version_obj.filename_version
newbinver = version_obj.binary_version
today = date.today()
print('Updating source files to version {0}\n'.format(newver))
print(f'Updating source files to version {newver}\n')
for myfile in GREGORIO_FILES:
result = []
following_line_filename = False
with open(myfile, 'r') as infile:
with open(myfile, 'r', encoding='utf-8') as infile:
for line in infile:
if 'AC_INIT([' in line:
result.append(re.sub(r'(\d+\.\d+\.\d+(?:[-+~]\w+)*)', newver, line, 1))
Expand All @@ -306,7 +314,8 @@ def replace_version(version_obj):
result.append(re.sub(r'(\d+\/\d+/\d+)', today.strftime("%Y/%m/%d"), newline, 1))
elif 'PARSE_VERSION_DATE' in line:
newline = re.sub(r'(\d+\.\d+\.\d+(?:[-+~]\w+)*)', newver, line, 1)
result.append(re.sub(r'(\d{1,2} [A-Z][a-z]+ \d{4})', today.strftime("%-d %B %Y"), newline, 1))
result.append(re.sub(r'(\d{1,2} [A-Z][a-z]+ \d{4})',
today.strftime("%-d %B %Y"), newline, 1))
elif 'FILEVERSION' in line:
result.append(re.sub(r'\d+,\d+,\d+,\d+', newbinver, line, 1))
elif 'PRODUCTVERSION' in line:
Expand All @@ -319,13 +328,14 @@ def replace_version(version_obj):
following_line_filename = False
else:
result.append(line)
with open(myfile, 'w') as outfile:
with open(myfile, 'w', encoding='utf-8') as outfile:
outfile.write(''.join(result))
sys.exit(0)

def update_changelog(newver,upgradetype):
def update_changelog(newver, upgradetype):
"Insert the version number into CHANGELOG"
today = date.today()
with open('CHANGELOG.md', 'r') as infile:
with open('CHANGELOG.md', 'r', encoding='utf-8') as infile:
result = []
develop = False
for line in infile:
Expand Down Expand Up @@ -361,17 +371,17 @@ def update_changelog(newver,upgradetype):
print("I didn't find a unreleased develop section.")
print("Non-patch releases should be based on develop branch.")
sys.exit(1)
with open('CHANGELOG.md', 'w') as outfile:
with open('CHANGELOG.md', 'w', encoding='utf-8') as outfile:
outfile.write(''.join(result))

def confirm_replace(oldver, newver):
"Query the user to confirm action"
query = 'Update version from {0} --> {1} [y/n]?'.format(oldver, newver)
query = f'Update version from {oldver} --> {newver} [y/n]?'
print(query)
consent = None
while True:
try:
consent = strtobool(raw_input().lower())
consent = strtobool(input().lower())
break
except ValueError:
print('Answer with y or n.')
Expand Down Expand Up @@ -478,7 +488,7 @@ def year_range(matchobj):
print('Updating copyright year.')
for myfile in COPYRIGHT_FILES:
result = []
with open(myfile, 'r') as infile:
with open(myfile, 'r', encoding='utf-8') as infile:
for line in infile:
if re.search(r'[C|c]opyright.*Gregorio Project', line):
result.append(re.sub(r'(\d{4}-)?(\d{4})', year_range, line))
Expand All @@ -490,7 +500,7 @@ def year_range(matchobj):
result.append(re.sub(r'(\d{4}-)?(\d{4})', year_range, line))
else:
result.append(line)
with open(myfile, 'w') as outfile:
with open(myfile, 'w', encoding='utf-8') as outfile:
outfile.write(''.join(result))

def main():
Expand Down
4 changes: 2 additions & 2 deletions contrib/900_gregorio.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@
\pagestyle{empty}
\setlength{\textwidth}{$scribus_realwidth$ pt}

\begin{filecontents*}[overwrite]{scribus_file-score.gabc}
\begin{filecontents*}[overwrite]{\jobname-score.gabc}
</preamble> <!-- this line's indentation is purposefully off because of the way that scribus interprets the preamble section -->
<postamble>
\end{filecontents*}

\begin{document}
$scribus_greconf$
\gregorioscore{scribus_file-score}
\gregorioscore{\jobname-score.gabc}
\end{document}
</postamble>
<tab type="settings">
Expand Down
21 changes: 12 additions & 9 deletions contrib/checkSyllabation.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@

"""


import os
import sys
import re
import glob
import argparse
import pyphen
import os
import glob


DEFAULT_OUTFILE = False
if os.name == 'nt':
Expand All @@ -62,7 +64,8 @@ def get_parser():
return parser

def deacc(accstr):
return accstr.replace('á', 'a').replace('é', 'e').replace('í', 'i').replace('ó', 'o').replace('ú', 'u').replace('ý', 'y').replace('́', '').replace('ǽ', 'æ')
"Remove accents from vowels"
return accstr.replace('á', 'a').replace('é', 'e').replace('í', 'i').replace('ó', 'o').replace('ú', 'u').replace('ý', 'y').replace('́', '').replace('ǽ', 'æ')

def checkwords(words_list, hyphenator):
errors = []
Expand Down Expand Up @@ -100,15 +103,15 @@ def get_words_list(gabc_content):
return gabc_content.split()

def get_file_list(path):
"Generate list of files to parse"
if os.path.isfile(path):
return [path]
elif os.path.isdir(path):
if os.path.isdir(path):
files = glob.glob(os.path.join(path, '**/*.gabc'), recursive=True)
files = sorted(files)
return files
else:
print('Error! Cannot find '+path, file=sys.stderr)
sys.exit(1)
print(f'Error! Cannot find {path}', file=sys.stderr)
sys.exit(1)

def check_file(filepath, hyphenator, outfd, report_no_error=False):
words_list = []
Expand Down Expand Up @@ -139,8 +142,8 @@ def main():
outfd = open(args.outfile, 'w', encoding='utf8')
file_list = get_file_list(args.path)
nb_errors = 0
for f in file_list:
nb_errors += check_file(f, hyphenator, outfd, args.verbose)
for filename in file_list:
nb_errors += check_file(filename, hyphenator, outfd, args.verbose)
if len(file_list) > 1 and nb_errors > 0:
outfd.write('Total errors: '+str(nb_errors)+'\n')
elif nb_errors == 0 and not args.verbose:
Expand Down
3 changes: 2 additions & 1 deletion doc/Command_Index_User.tex
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ \subsubsection{Including scores}
\gresetgregpath{{../Scores/}}
\end{latexcode}

Note that these directories are not searched recursively. If you want to include subdirectories, then each subdirectory must be included individually.
\macroname{\textbackslash gresetoutputdir}{\{\#1\}}{gregoriotex-main.tex}
Sets the name of the output directory where gtex and glog files will be written. By default this is tmp-gre of the current directory. Use this command to relocate these files to some other directory.


\macroname{\textbackslash gresetcompilegabc}{\{\#1\}}{gregoriotex-main.tex}
Expand Down
7 changes: 3 additions & 4 deletions fonts/convertsfdtottf.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@
"""


from __future__ import print_function

import getopt, sys
import sys
import getopt
import fontforge


Expand Down Expand Up @@ -64,7 +63,7 @@ def main():
usage()
sys.exit(2)
if args[0][-3:] == "sfd":
outputfile = "%s.ttf" % args[0][:-4]
outputfile = f'{args[0][:-4]}.ttf'
inputfile = args[0]
else:
usage()
Expand Down
5 changes: 2 additions & 3 deletions fonts/simplify.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@
"""


from __future__ import print_function

import getopt, sys
import sys
import getopt
import fontforge


Expand Down
11 changes: 5 additions & 6 deletions fonts/squarize.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
own glyphs from it.
"""

from __future__ import print_function

import sys
import os
Expand Down Expand Up @@ -68,7 +67,7 @@
# defines the maximal interval between two notes, the bigger this number is,
# the more glyphs you'll have to generate
MAX_INTERVAL = 5
ALL_AMBITUS = range(1, MAX_INTERVAL + 1)
ALL_AMBITUS = list(range(1, MAX_INTERVAL + 1))
AMBITUS_ONE_ONLY = [ 1 ]

# this dictionary must have a value for 0 to 14 (the maximum overall ambitus)
Expand Down Expand Up @@ -229,7 +228,7 @@ def set_glyph_name(name):
global all_glyph_names, newfont, glyphnumber
if glyphnumber in newfont:
if name in all_glyph_names:
print("ERROR: duplicate glyph name [%s]" % name, file=sys.stderr)
print(f'ERROR: duplicate glyph name [{name}]', file=sys.stderr)
sys.exit(1)
else:
all_glyph_names[name] = True
Expand Down Expand Up @@ -440,7 +439,7 @@ def glyph_exists(glyph_name):
result = True
try:
oldfont.selection.select(glyph_name + '')
except Exception as ex:
except Exception:
result = False
GLYPH_EXISTS[glyph_name] = result
return result
Expand Down Expand Up @@ -1132,7 +1131,7 @@ def measures():
def hepisema():
"Creates horizontal episemata."
message("horizontal episema")
for target, source in HEPISEMA_GLYPHS.items():
for target, source in list(HEPISEMA_GLYPHS.items()):
write_hepisema(get_width(source), target)
write_hepisema(get_width(source) * 2.0 / 3.0, target + "Reduced")
reduction = get_width('PunctumSmall')
Expand Down Expand Up @@ -2492,7 +2491,7 @@ def scandicus():
write_all_scandicus('rdeminutus', L_DEMINUTUS)

def write_all_scandicus(last_glyph, lique=L_NOTHING, i_range=ALL_AMBITUS,
j_range=ALL_AMBITUS):
j_range=ALL_AMBITUS):
for i in i_range:
for j in j_range:
write_scandicus(i, j, last_glyph, lique)
Expand Down
4 changes: 2 additions & 2 deletions fonts/stemsschemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,6 @@ def get_stem_schema(schemaname, font_config):
"""
if schemaname == 'default':
return get_stem_schema_default(font_config)
elif schemaname == 'solesmes':
if schemaname == 'solesmes':
return get_stem_schema_solesmes(font_config)
print('impossible to find schema %s, quitting' % schemaname)
print(f'impossible to find schema {schemaname}, quitting')
Loading