# along with this program. If not, see <http://www.gnu.org/licenses/>. import os import tempfile from sdaps import model from sdaps import script from sdaps import log from sdaps.utils.ugettext import ugettext, ungettext _ = ugettext parser = script.add_project_subparser("add", help=_("Add scanned questionnaires to the survey."), description=_("""This command is used to add scanned images to the survey. The image data needs to be a (multipage) 300dpi monochrome TIFF file. You may choose not to copy the data into the project directory. In that case the data will be referenced using a relative path.""")) parser.add_argument('--convert', help=_("Convert given files and add the result."), dest="convert", action="store_true", default=False) parser.add_argument('--3d-transform', help=_("""Do a 3D-transformation after finding the corner marks. If the corner marks are not found then the image will be added as-is."""), dest="transform", action="store_true", default=False) parser.add_argument('--force',
# # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. from sdaps import model from sdaps import script import os import sys from sdaps.utils.ugettext import ugettext, ungettext _ = ugettext parser = script.add_project_subparser("ids", help=_("Export and import questionnaire IDs."), description=_("""This command can be used to import and export questionnaire IDs. It only makes sense in projects where such an ID is printed on the questionnaire. Note that you can also add IDs by using the stamp command, which will give you the PDF at the same time.""")) parser.add_argument('-o', '--output', help=_("Filename to store the data to (default: ids_%%i)")) parser.add_argument('-a', '--add', metavar="FILE", help=_("Add IDs to the internal list from the specified file.")) @script.connect(parser) @script.logfile def ids(cmdline): survey = model.survey.Survey.load(cmdline['project']) if cmdline['add']: if cmdline['add'] == '-':
import os import sys from sdaps import model from sdaps import script from sdaps import log from sdaps.utils.ugettext import ugettext, ungettext _ = ugettext parser = script.add_project_subparser("convert", help=_("Convert a set of images to the correct image format."), description=_("""This command can be used if you scanned files in something other than the expected monochrome TIFF mode. All given files will be loaded, converted to monochrome and stored in a multipage 1bpp TIFF file. Optionally, you can select \"3D transformation"\ ,which may facilitate working with photos of questionnaires instead of scans.""")) parser.add_argument('--3d-transform', help=_("""Do a 3D-transformation after finding the corner marks. If they are not found, the image will be processed as-is."""), dest="transform", action="store_true", default=False) parser.add_argument('-o', '--output', required=True, help=_("The location of the output file."), dest="output") parser.add_argument('images',
# This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. from sdaps import model from sdaps import script from sdaps.utils.ugettext import ugettext, ungettext _ = ugettext parser = script.add_project_subparser("report", help=_("Create a PDF report."), description=_("""This command creates a PDF report using reportlab that contains statistics and if selected the freeform fields.""")) parser.add_argument('-f', '--filter', help=_("Filter to only export a partial dataset.")) parser.add_argument('--all-filters', help=_("Create a filtered report for every checkbox."), action="store_true") parser.add_argument('-s', '--short', help=_("Short format (without freeform text fields)."), action="store_const", const="short", dest="format") parser.add_argument('-l', '--long', help=_("Detailed output. (default)"), dest="format",
# but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. from sdaps import model from sdaps import script from sdaps.utils.ugettext import ugettext, ungettext _ = ugettext parser = script.add_project_subparser("cover", help=_("Create a cover for the questionnaires."), description=_("""This command creates a cover page for questionnaires. All the metadata of the survey will be printed on the page.""")) parser.add_argument('-o', '--output', help=_("Filename to store the data to (default: cover_%%i.pdf)")) @script.connect(parser) @script.logfile def cover(cmdline): from sdaps import cover survey = model.survey.Survey.load(cmdline['project']) cover.cover(survey, cmdline['output'])
# GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. from sdaps import model from sdaps import script from sdaps import log from sdaps.utils.ugettext import ugettext, ungettext _ = ugettext parser = script.add_project_subparser( "info", help=_("Display and modify metadata of project."), description=_("""This command lets you modify the metadata of the SDAPS project. You can modify, add and remove arbitrary keys that will be printed on the report. The only key that always exist is "title". If no key is given then a list of defined keys is printed.""")) parser.add_argument('-d', '--delete', action="store_true", help=_("Delete the key and value pair.")) parser.add_argument('key', nargs="?", help=_("The key to display or modify.")) parser.add_argument('value', nargs="?", help=_("Set the given key to this value."))
# GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. from sdaps import model from sdaps import script from sdaps import defs from sdaps.utils.ugettext import ugettext, ungettext _ = ugettext parser = script.add_project_subparser("setup", help=_("Create a new survey using a LaTeX document."), description=_("""Create a new survey from a LaTeX document. You need to be using the SDAPS class. All the metadata and options for the project can be set inside the LaTeX document.""")) parser.add_argument('questionnaire.tex', help=_("The LaTeX Document")) parser.add_argument('-a', '--add', help=_("Additional files that are required by the LaTeX document and need to be copied into the project directory."), action='append', default=[]) parser.add_argument('-e', '--engine', help=_("The engine to use to compile LaTeX documents."), default=defs.latex_engine) parser.add_argument('additional_questions', nargs='?', help=_("Additional questions that are not part of the questionnaire."))
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. from sdaps import model from sdaps import script from sdaps.utils.ugettext import ugettext, ungettext _ = ugettext parser = script.add_project_subparser( "gui", help=_( "Launch a GUI. You can view and alter the (recognized) answers with it." ), description=_("""This command launches a graphical user interface that can be used to correct answers. You need to run "recognize" before using it. """)) parser.add_argument('-f', '--filter', help=_("Filter to only show a partial dataset.")) @script.connect(parser) @script.logfile def gui(cmdline): from sdaps import gui survey = model.survey.Survey.load(cmdline['project'])
# This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. from sdaps import model from sdaps import script from sdaps.utils.ugettext import ugettext, ungettext _ = ugettext parser = script.add_project_subparser("report_tex", help=_("Create a PDF report using LaTeX."), description=_("""This command creates a PDF report using LaTeX that contains statistics and freeform fields.""")) parser.add_argument('--suppress-images', help=_('Do not include original images in the report. This is useful if there are privacy concerns.'), dest='suppress', action='store_const', const='images') parser.add_argument('--suppress-substitutions', help=_('Do not use substitutions instead of images.'), dest='suppress', action='store_const', const='substitutions', default=None) parser.add_argument('--create-tex', help=_('Save the generated TeX files instead of the final PDF.'), dest='create-tex',
import os import tempfile from sdaps import model from sdaps import script from sdaps import log from sdaps.utils.ugettext import ugettext, ungettext _ = ugettext parser = script.add_project_subparser( "add", help=_("Add scanned questionnaires to the survey."), description=_("""This command is used to add scanned images to the survey. The image data needs to be a (multipage) 300dpi monochrome TIFF file. You may choose not to copy the data into the project directory. In that case the data will be referenced using a relative path.""")) parser.add_argument('--convert', help=_("Convert given files and add the result."), dest="convert", action="store_true", default=False) parser.add_argument( '--3d-transform', help=_("""Do a 3D-transformation after finding the corner marks. If the corner marks are not found then the image will be added as-is."""), dest="transform", action="store_true",
# GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. from sdaps import model from sdaps import script from sdaps.utils.ugettext import ugettext, ungettext _ = ugettext parser = script.add_project_subparser("reorder", help=_("Reorder pages according to questionnaire ID."), description=_("""This command reorders all pages according to the already recognized questionnaire ID. To use it add all the files to the project, then run a partial recognition using "recognize --identify". After this you have to run this command to reorder the data for the real recognition. """)) @script.connect(parser) @script.logfile def reorder(cmdline): survey = model.survey.Survey.load(cmdline['project']) from sdaps import reorder return reorder.reorder(survey)
# GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. from sdaps import model from sdaps import script from sdaps.utils.ugettext import ugettext, ungettext _ = ugettext parser = script.add_project_subparser("gui", help=_("Launch a GUI. You can view and alter the (recognized) answers with it."), description=_("""This command launches a graphical user interface that can be used to correct answers. You need to run "recognize" before using it. """)) parser.add_argument('-f', '--filter', help=_("Filter to only show a partial dataset.")) @script.connect(parser) @script.logfile def gui(cmdline): from sdaps import gui survey = model.survey.Survey.load(cmdline['project']) return gui.gui(survey, cmdline)
# but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. from sdaps import model from sdaps import script from sdaps.utils.ugettext import ugettext, ungettext _ = ugettext parser = script.add_project_subparser("reset", help=_("Reset project into original state"), description=_("""This command does a full reset of the project. All data will be discarded and only the empty project is left. """)) @script.connect(parser) @script.logfile def reset(cmdline): survey = model.survey.Survey.load(cmdline['project']) from sdaps import reset return reset.reset(survey)
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. import os from sdaps import model from sdaps import script from sdaps.utils.ugettext import ugettext, ungettext _ = ugettext parser = script.add_project_subparser("annotate", help=_("Annotate the questionnaire and show the recognized positions."), description=_("""This command is mainly a debug utility. It creates an annotated version of the questionnaire, with the information that SDAPS knows about it overlayed on top.""")) @script.connect(parser) @script.logfile def annotate(cmdline): from sdaps.annotate import annotate survey = model.survey.Survey.load(cmdline['project']) return annotate(survey)
# project = 'None' # # loop over the detected barcodes # for barcode in barcodes: # barcodedata = barcode.data.decode("utf-8") # if len(barcodedata) == 9: # facturation = barcodedata # print(facturation) # elif len(barcodedata) == 14: # project = barcodedata[0:-4] # print(project) # print(project , facturation) # return (project , facturation) parser = script.add_project_subparser( "watch", help=_("Watching for new scan commit"), description=_("""Watch in a specified folder to detect a new scan, convert and push it to the right project.""")) parser.add_argument('--scanFolder', '-sf', help=_("Folder to be watched")) parser.add_argument('--projectsFolder', '-pf', help=_("Folder containing SDAPS projects")) parser.add_argument('--renamedFolder', '-rf', help=_("Folder with renamed and processed scans")) @script.connect(parser)
# You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. from sdaps import model from sdaps import script import os import sys from sdaps.utils.ugettext import ugettext, ungettext _ = ugettext parser = script.add_project_subparser( "ids", help=_("Export and import questionnaire IDs."), description=_( """This command can be used to import and export questionnaire IDs. It only makes sense in projects where such an ID is printed on the questionnaire. Note that you can also add IDs by using the stamp command, which will give you the PDF at the same time.""")) parser.add_argument('-o', '--output', help=_("Filename to store the data to (default: ids_%%i)")) parser.add_argument( '-a', '--add', metavar="FILE", help=_("Add IDs to the internal list from the specified file.")) @script.connect(parser) @script.logfile
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. import os from sdaps import model from sdaps import script from sdaps.utils.ugettext import ugettext, ungettext _ = ugettext parser = script.add_project_subparser( "annotate", help=_("Annotate the questionnaire and show the recognized positions."), description=_("""This command is mainly a debug utility. It creates an annotated version of the questionnaire, with the information that SDAPS knows about it overlayed on top.""")) @script.connect(parser) @script.logfile def annotate(cmdline): from sdaps.annotate import annotate survey = model.survey.Survey.load(cmdline['project']) return annotate(survey)
# GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. from sdaps import model from sdaps import script from sdaps import log from sdaps.utils.ugettext import ugettext, ungettext _ = ugettext parser = script.add_project_subparser("info", help=_("Display and modify metadata of project."), description=_("""This command lets you modify the metadata of the SDAPS project. You can modify, add and remove arbitrary keys that will be printed on the report. The only key that always exist is "title". If no key is given then a list of defined keys is printed.""")) parser.add_argument('-d', '--delete', action="store_true", help=_("Delete the key and value pair.")) parser.add_argument('key', nargs="?", help=_("The key to display or modify.")) parser.add_argument('value', nargs="?", help=_("Set the given key to this value."))
# but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. from sdaps import model from sdaps import script from sdaps.utils.ugettext import ugettext, ungettext _ = ugettext parser = script.add_project_subparser("stamp", help=_("Add marks for automatic processing."), description=_("""This command creates the printable document. Depending on the projects setting you are required to specifiy a source for questionnaire IDs.""")) parser.add_argument('-r', '--random', metavar="N", help=_("If using questionnaire IDs, create N questionnaires with randomized IDs."), type=int) parser.add_argument('-f', '--file', help=_("If using questionnaire IDs, create questionnaires from the IDs read from the specified file.")) parser.add_argument('--existing', action="store_true", help=_("If using questionnaire IDs, create questionnaires for all stored IDs.")) parser.add_argument('-o', '--output', help=_("Filename to store the data to (default: stamp_%%i.pdf)"))
""" This modules contains a script for the user to output all boxes sorted by their coverage. This can be used to adjust magic values for checkbox recognition. """ from sdaps import model from sdaps import script from sdaps.utils.ugettext import ugettext, ungettext _ = ugettext parser = script.add_project_subparser( "boxgallery", help=_("Create PDFs with boxes sorted by the detection heuristics."), description=_("""SDAPS uses multiple heuristics to detect determine the state of checkboxes. There is a list for each heuristic giving the expected state and the quality of the value (see defs.py). Using this command a PDF will be created for each of the heuristics so that one can adjust the values.""")) parser.add_argument( '--debugrecognition', action="store_true", help= _('Reruns part of the recognition process and retrieves debug images from this step.' ), default=False) @script.connect(parser) @script.logfile
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. from sdaps import model from sdaps import script from sdaps.utils.ugettext import ugettext, ungettext _ = ugettext parser = script.add_project_subparser( "reorder", help=_("Reorder pages according to questionnaire ID."), description=_("""This command reorders all pages according to the already recognized questionnaire ID. To use it add all the files to the project, then run a partial recognition using "recognize --identify". After this you have to run this command to reorder the data for the real recognition. """)) @script.connect(parser) @script.logfile def reorder(cmdline): survey = model.survey.Survey.load(cmdline['project']) from sdaps import reorder return reorder.reorder(survey)
# but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. from sdaps import model from sdaps import script from sdaps.utils.ugettext import ugettext, ungettext _ = ugettext parser = script.add_project_subparser( "cover", help=_("Create a cover for the questionnaires."), description=_("""This command creates a cover page for questionnaires. All the metadata of the survey will be printed on the page.""")) parser.add_argument( '-o', '--output', help=_("Filename to store the data to (default: cover_%%i.pdf)")) @script.connect(parser) @script.logfile def cover(cmdline): from sdaps import cover survey = model.survey.Survey.load(cmdline['project'])
# GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. from sdaps import model from sdaps import script from sdaps.utils.ugettext import ugettext, ungettext _ = ugettext parser = script.add_project_subparser("recognize", help=_("Run the optical mark recognition."), description=_("""Iterates over all images and runs the optical mark recognition. It will reevaluate sheets even if "recognize" has already run or manual changes were made.""")) parser.add_argument('--identify', help=_("Only identify the page properties, but don't recognize the checkbox states."), action="store_true", default=False) parser.add_argument('--rerun', '-r', help=_("Rerun the recognition for all pages. The default is to skip all pages that were recognized or verified already."), action="store_true", default=False) @script.connect(parser) @script.logfile
# GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. from sdaps import model from sdaps import script from sdaps import defs from sdaps.utils.ugettext import ugettext, ungettext _ = ugettext parser = script.add_project_subparser( "setup", help=_("Create a new survey using a LaTeX document."), description=_("""Create a new survey from a LaTeX document. You need to be using the SDAPS class. All the metadata and options for the project can be set inside the LaTeX document.""")) parser.add_argument('questionnaire.tex', help=_("The LaTeX Document")) parser.add_argument( '-a', '--add', help= _("Additional files that are required by the LaTeX document and need to be copied into the project directory." ), action='append', default=[]) parser.add_argument('-e', '--engine', help=_("The engine to use to compile LaTeX documents."),