Added the handler of the macro password (thanks to denis mourier <denis.mourier2@gmail.com>). Advanced to version 0.8.
This commit is contained in:
parent
548a5f538b
commit
ffbff69f2b
31
bin/obasync
31
bin/obasync
@ -102,6 +102,7 @@ LIBRARY The name of the Basic library. Default to the same
|
||||
|
||||
from __future__ import print_function
|
||||
import argparse
|
||||
import getpass
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
@ -220,7 +221,7 @@ def parse_args():
|
||||
" an \"Untitied 1\" (in your language) if it is a new"
|
||||
" file."))
|
||||
parser.add_argument(
|
||||
"-v", "--version", action="version", version="%(prog)s 0.7")
|
||||
"-v", "--version", action="version", version="%(prog)s 0.8")
|
||||
args = parser.parse_args()
|
||||
|
||||
# Obtain the absolute path
|
||||
@ -304,8 +305,8 @@ def find_doc(oo, target):
|
||||
if target is None:
|
||||
if len(opened) == 1:
|
||||
return opened[0]
|
||||
print("ERROR: There are more than one opened documens."
|
||||
" Please specify the file path.",
|
||||
print("ERROR: There are more than one opened documens. "
|
||||
"Please specify the file path.",
|
||||
file=sys.stderr)
|
||||
for path in get_doc_paths(opened, file_content_provider):
|
||||
print("* %s" % path, file=sys.stderr)
|
||||
@ -443,6 +444,7 @@ def read_basic_modules(storage, libname):
|
||||
modules = {}
|
||||
if not storage.libs.hasByName(libname):
|
||||
return modules
|
||||
verify_library_password(storage, libname)
|
||||
storage.libs.loadLibrary(libname)
|
||||
library = storage.libs.getByName(libname)
|
||||
for modname in library.getElementNames():
|
||||
@ -464,11 +466,13 @@ def update_basic_modules(storage, libname, modules):
|
||||
storage.libs.createLibrary(libname)
|
||||
print("Script library %s created." % libname, file=sys.stderr)
|
||||
create_dialog_library(storage, libname)
|
||||
verify_library_password(storage, libname)
|
||||
library = storage.libs.getByName(libname)
|
||||
for modname in sorted(modules.keys()):
|
||||
library.insertByName(modname, modules[modname])
|
||||
print("Module %s added." % modname, file=sys.stderr)
|
||||
else:
|
||||
verify_library_password(storage, libname)
|
||||
storage.libs.loadLibrary(libname)
|
||||
library = storage.libs.getByName(libname)
|
||||
# As of OpenOffice 4.1.3, when there is no modules in the
|
||||
@ -514,6 +518,27 @@ def create_dialog_library(storage, libname):
|
||||
libraries.storeLibraries()
|
||||
|
||||
|
||||
def verify_library_password(storage, libname):
|
||||
"""Verify the password for the library.
|
||||
|
||||
Arguments:
|
||||
storage: The Basic macro storage, as a Storage object.
|
||||
libname: The name of the dialog library.
|
||||
password: The password for the library.
|
||||
"""
|
||||
if not storage.libs.isLibraryPasswordProtected(libname):
|
||||
return
|
||||
if storage.libs.isLibraryPasswordVerified(libname):
|
||||
return
|
||||
while True:
|
||||
password = getpass.getpass("Password: ")
|
||||
if storage.libs.verifyLibraryPassword(libname, password):
|
||||
return
|
||||
print("ERROR: Failed password for library %s." % libname,
|
||||
file=sys.stderr)
|
||||
return
|
||||
|
||||
|
||||
def run_macro(storage, libname, macro):
|
||||
"""Run a Basic macro.
|
||||
|
||||
|
2
setup.py
2
setup.py
@ -29,7 +29,7 @@ if os.path.basename(sys.executable) == "python.bin":
|
||||
os.path.dirname(sys.executable), "python")
|
||||
|
||||
setup(name="obasync",
|
||||
version="0.7",
|
||||
version="0.8",
|
||||
description="Office Basic macro source synchronizer",
|
||||
url="https://pypi.python.org/pypi/obasync",
|
||||
author="imacat",
|
||||
|
Loading…
Reference in New Issue
Block a user