mirror of https://gitlab.com/bashrc2/epicyon
Adding to minimize file
parent
3e93474aab
commit
dbbd7fae41
|
@ -63,46 +63,39 @@ def _minimize_attached_images(base_dir: str, nickname: str, domain: str,
|
||||||
|
|
||||||
# get the contents of the minimize file, which is
|
# get the contents of the minimize file, which is
|
||||||
# a set of handles
|
# a set of handles
|
||||||
following_handles = ''
|
minimize_handles = ''
|
||||||
if os.path.isfile(minimize_filename):
|
if os.path.isfile(minimize_filename):
|
||||||
print('Minimize file exists')
|
print('Minimize file exists')
|
||||||
try:
|
try:
|
||||||
with open(minimize_filename, 'r',
|
with open(minimize_filename, 'r',
|
||||||
encoding='utf-8') as minimize_file:
|
encoding='utf-8') as minimize_file:
|
||||||
following_handles = minimize_file.read()
|
minimize_handles = minimize_file.read()
|
||||||
except OSError:
|
except OSError:
|
||||||
print('EX: minimize_attached_images ' + minimize_filename)
|
print('EX: minimize_attached_images ' + minimize_filename)
|
||||||
else:
|
else:
|
||||||
# create a new minimize file from the following file
|
# create a new minimize file from the following file
|
||||||
print('Creating minimize file ' + minimize_filename)
|
print('Creating minimize file ' + minimize_filename)
|
||||||
following_handles = ''
|
|
||||||
try:
|
|
||||||
with open(following_filename, 'r',
|
|
||||||
encoding='utf-8') as following_file:
|
|
||||||
following_handles = following_file.read()
|
|
||||||
except OSError:
|
|
||||||
print('EX: minimize_attached_images 2 ' + minimize_filename)
|
|
||||||
if add:
|
if add:
|
||||||
try:
|
try:
|
||||||
with open(minimize_filename, 'w+',
|
with open(minimize_filename, 'w+',
|
||||||
encoding='utf-8') as fp_min:
|
encoding='utf-8') as fp_min:
|
||||||
fp_min.write(following_handles + handle + '\n')
|
fp_min.write('')
|
||||||
except OSError:
|
except OSError:
|
||||||
print('EX: minimize_attached_images unable to write ' +
|
print('EX: minimize_attached_images unable to write ' +
|
||||||
minimize_filename)
|
minimize_filename)
|
||||||
|
|
||||||
# already in the minimize file?
|
# already in the minimize file?
|
||||||
if handle + '\n' in following_handles:
|
if handle + '\n' in minimize_handles:
|
||||||
print(handle + ' exists in followingMinimizeImages.txt')
|
print(handle + ' exists in followingMinimizeImages.txt')
|
||||||
if add:
|
if add:
|
||||||
# already added
|
# already added
|
||||||
return
|
return
|
||||||
# remove from minimize file
|
# remove from minimize file
|
||||||
following_handles = following_handles.replace(handle + '\n', '')
|
minimize_handles = minimize_handles.replace(handle + '\n', '')
|
||||||
try:
|
try:
|
||||||
with open(minimize_filename, 'w+',
|
with open(minimize_filename, 'w+',
|
||||||
encoding='utf-8') as fp_min:
|
encoding='utf-8') as fp_min:
|
||||||
fp_min.write(following_handles)
|
fp_min.write(minimize_handles)
|
||||||
except OSError:
|
except OSError:
|
||||||
print('EX: minimize_attached_images 3 ' + minimize_filename)
|
print('EX: minimize_attached_images 3 ' + minimize_filename)
|
||||||
else:
|
else:
|
||||||
|
@ -110,11 +103,11 @@ def _minimize_attached_images(base_dir: str, nickname: str, domain: str,
|
||||||
# not already in the minimize file
|
# not already in the minimize file
|
||||||
if add:
|
if add:
|
||||||
# append to the list of handles
|
# append to the list of handles
|
||||||
following_handles += handle + '\n'
|
minimize_handles += handle + '\n'
|
||||||
try:
|
try:
|
||||||
with open(minimize_filename, 'w+',
|
with open(minimize_filename, 'w+',
|
||||||
encoding='utf-8') as fp_min:
|
encoding='utf-8') as fp_min:
|
||||||
fp_min.write(following_handles)
|
fp_min.write(minimize_handles)
|
||||||
except OSError:
|
except OSError:
|
||||||
print('EX: minimize_attached_images 4 ' + minimize_filename)
|
print('EX: minimize_attached_images 4 ' + minimize_filename)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue