Skip to content

Commit

Permalink
Format strings more nicely
Browse files Browse the repository at this point in the history
  • Loading branch information
dkratzert committed Oct 4, 2023
1 parent eb46856 commit ec9e6a4
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions src/dsr_shelx/dsr.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class DSR(object):
main class
"""

def __init__(self, options):
def __init__(self, options: OptionsParser):
"""
"""
time1 = time.perf_counter()
Expand Down Expand Up @@ -367,12 +367,11 @@ def main(self):

# Adds the origin of restraints and fragment to res file:
import textwrap
source = textwrap.wrap("REM Restraints for Fragment {}, {} from: {}. "
"Please cite https://doi.org/10.1107/S1600576718004508".format(
self.fragment,
self.gdb.get_fragment_name(self.fragment),
self.gdb.get_src(self.fragment)),
width=74, subsequent_indent='REM ')
source = textwrap.wrap(f"REM Restraints for Fragment {self.fragment}, "
f"{self.gdb.get_fragment_name(self.fragment)} "
f"from: {self.gdb.get_src(self.fragment)}. "
f"Please cite https://doi.org/10.1107/S1600576718004508",
width=74, subsequent_indent='REM ')
if dsrp.resi:
hfixes = '\n'.join(self.gdb.get_hfixes(self.fragment, resi.get_residue_class))
if hfixes:
Expand Down Expand Up @@ -443,26 +442,26 @@ def main():
try:
options = OptionsParser(program_name)
if is_listfile:
lstfile.write('Python version: {}\n'.format(sys.version))
lstfile.write("Date: {} \n".format(datetime.now().strftime("%Y-%m-%d %H:%M:%S")))
lstfile.write(f'Python version: {sys.version}\n')
lstfile.write(f"Date: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')} \n")
lstfile.write(options.__str__())
DSR(options)
except Exception:
import platform

if is_listfile:
lstpath = os.path.abspath(lstfile.name)
lst = 'the file "{}" \nand '.format(lstpath)
lst = f'the file "{lstpath}" \nand '
else:
lst = "this error message and "
print('\n*** Congratulations! You found a bug in DSR. Please send {}the .res file '
'(if possible) to dkratzert@gmx.de ***\n\n'.format(lst))
print('DSR version: {}'.format(VERSION))
print('Python version: {}'.format(sys.version))
print(
f'\n*** Congratulations! You found a bug in DSR. Please send {lst}the'
f' .res file (if possible) to dkratzert@gmx.de ***\n\n')
print(f'DSR version: {VERSION}')
print(f'Python version: {sys.version}')
if options:
print('Commandline: {}'.format(options.all_options))
print('Platform: {} {}, {}'.format(platform.system(),
platform.release(), ' '.join(platform.uname())))
print(f'Commandline: {options.all_options}')
print(f'Platform: {platform.system()} {platform.release()}, {" ".join(platform.uname())}')
print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
raise

Expand Down

0 comments on commit ec9e6a4

Please sign in to comment.