def main(): """main""" default_config = os.path.join(os.path.dirname(os.path.abspath(__file__)), "cctools.cfg") now = datetime.datetime.now() default_xlsx_filename = now.strftime("%Y-%m-%d-PurchaseOrder.xlsx") arg_parser = argparse.ArgumentParser( description="Generates a FedEx Product Dictionary.") arg_parser.add_argument( "--config", action="store", dest="config", metavar="FILE", default=default_config, help="configuration filename (default=%(default)s)") arg_parser.add_argument("--outfile", action="store", dest="xlsx_filename", metavar="FILE", default=default_xlsx_filename, help="output XLSX filename (default=%(default)s)") arg_parser.add_argument("--exclude-sku", action="append", dest="exclude_skus", metavar="SKU", help="exclude SKU from output") arg_parser.add_argument("--verbose", action="store_true", default=False, help="display progress messages") # Parse command line arguments. args = arg_parser.parse_args() # Configure logging. logging.basicConfig( level=logging.INFO if args.verbose else logging.WARNING) logger = logging.getLogger() # Also log using notify-send if it is available. if notify_send_handler.NotifySendHandler.is_available(): logger.addHandler( notify_send_handler.NotifySendHandler( os.path.splitext(os.path.basename(__file__))[0])) # Read config file. config = ConfigParser.RawConfigParser() config.readfp(open(args.config)) # Create a connection to CoreCommerce. cc_browser = cctools.CCBrowser(config.get("website", "base_url"), config.get("website", "username"), config.get("website", "password")) # Fetch products list. products = cc_browser.get_products() # Generate spreadsheet. logger.debug("Generating {}".format(os.path.abspath(args.xlsx_filename))) generate_xlsx(args, cc_browser, products) logger.debug("Generation complete") return 0
def main(): """main""" default_config = os.path.join( os.path.dirname(os.path.abspath(__file__)), "cctools.cfg" ) now = datetime.datetime.now() default_xlsx_filename = now.strftime("%Y-%m-%d-InventoryTracker.xlsx") arg_parser = argparse.ArgumentParser( description="Generates an inventory report." ) arg_parser.add_argument( "--config", metavar="FILE", default=default_config, help="configuration filename (default=%(default)s)" ) arg_parser.add_argument( "--outfile", dest="xlsx_filename", metavar="FILE", default=default_xlsx_filename, help="output XLSX filename (default=%(default)s)" ) arg_parser.add_argument( "--sort", dest="sort", choices=["SKU", "CAT/PROD"], default="SKU", help="sort order (default=%(default)s)" ) arg_parser.add_argument( "--verbose", action="store_true", default=False, help="display progress messages" ) # Parse command line arguments. args = arg_parser.parse_args() # Configure logging. logging.basicConfig( level=logging.INFO if args.verbose else logging.WARNING ) logger = logging.getLogger() # Also log using notify-send if it is available. if notify_send_handler.NotifySendHandler.is_available(): logger.addHandler( notify_send_handler.NotifySendHandler( os.path.splitext(os.path.basename(__file__))[0] ) ) # Read config file. config = ConfigParser.RawConfigParser() config.readfp(open(args.config)) # Get inventory info. inventory = fetch_inventory(args, config) # Create spreadsheet. logger.debug("Generating %s", args.xlsx_filename) generate_xlsx(args, inventory) logger.debug("Generation complete") return 0
def main(): """main""" # Construct default filename of configuration file. default_config = os.path.join(os.path.dirname(os.path.abspath(__file__)), "cctools.cfg") now = datetime.datetime.now() default_pdf_filename = now.strftime("%Y-%m-%d-WholesaleOrderForm.pdf") arg_parser = argparse.ArgumentParser( description=("Generates a printable wholesale order form " "from CoreCommerce data.")) arg_parser.add_argument( "--config", metavar="FILE", default=default_config, help="configuration filename (default=%(default)s)") arg_parser.add_argument("--category", action="append", dest="categories", metavar="CAT", help="include category in output") arg_parser.add_argument("--exclude-category", action="append", dest="exclude_categories", metavar="CAT", help="exclude category from output") arg_parser.add_argument("--exclude-sku", action="append", dest="exclude_skus", metavar="SKU", help="exclude SKU from output") arg_parser.add_argument("--pdf-file", metavar="FILE", default=default_pdf_filename, help="output PDF filename (default=%(default)s)") arg_parser.add_argument("--add-sku", dest="add_sku", action="store_true", default=False, help="append SKU to product name") arg_parser.add_argument("--ncols", type=int, metavar="N", default=2, help="number of report columns (default=2)") arg_parser.add_argument("--greybar-interval", type=int, metavar="N", default=2, help="greybar interval (default=%(default)i)") arg_parser.add_argument( "--wholesale-fraction", metavar="FRAC", default=0.5, help="wholesale price fraction (default=%(default).2f)") arg_parser.add_argument("--verbose", action="store_true", default=False, help="display progress messages") # Parse command line arguments. args = arg_parser.parse_args() if args.categories and args.exclude_categories: arg_parser.error("--category and --exclude-category specified") # Configure logging. logging.basicConfig( level=logging.INFO if args.verbose else logging.WARNING) logger = logging.getLogger() # Also log using notify-send if it is available. if notify_send_handler.NotifySendHandler.is_available(): logger.addHandler( notify_send_handler.NotifySendHandler( os.path.splitext(os.path.basename(__file__))[0])) # Read config file. config = ConfigParser.SafeConfigParser({ "body_fontsize": "12", "row_padding": "0", "title": "Wholesale Order" }) config.readfp(open(args.config)) # Create a connection to CoreCommerce. cc_browser = cctools.CCBrowser(config.get("website", "base_url"), config.get("website", "username"), config.get("website", "password")) # Get product list. products = get_products(args, cc_browser) # Generate PDF file. logger.debug("Generating {}\n".format(os.path.abspath(args.pdf_file))) generate_pdf(args, config, cc_browser, products) logger.debug("Generation complete") return 0
def main(): """main""" default_config = os.path.join( os.path.dirname(os.path.abspath(__file__)), "cctools.cfg" ) today = datetime.date.today() default_pdf_filename = "{:4}-{:02}-{:02}-ArtMartCheckInOut.pdf".format( today.year, today.month, today.day ) arg_parser = argparse.ArgumentParser( description="Generates an Art Mart Inventory Sheet in PDF form." ) arg_parser.add_argument( "--config", dest="config", metavar="FILE", default=default_config, help="configuration filename (default=%(default)s)" ) arg_parser.add_argument( "--quantfile", dest="quant_filename", metavar="CSV_FILE", default="ArtMartQuantities.csv", help="input product quantities filename (default=%(default)s)" ) arg_parser.add_argument( "--outfile", dest="pdf_filename", metavar="PDF_FILE", default=default_pdf_filename, help="output PDF filename (default=%(default)s)" ) arg_parser.add_argument( "--write-quant", action="store_true", dest="write_quant", default=False, help="write template quantity file instead of PDF" ) arg_parser.add_argument( "--verbose", action="store_true", default=False, help="display progress messages" ) # Parse command line arguments. args = arg_parser.parse_args() # Configure logging. logging.basicConfig( level=logging.INFO if args.verbose else logging.WARNING ) logger = logging.getLogger() # Also log using notify-send if it is available. if notify_send_handler.NotifySendHandler.is_available(): logger.addHandler( notify_send_handler.NotifySendHandler( os.path.splitext(os.path.basename(__file__))[0] ) ) # Read config file. config = ConfigParser.RawConfigParser() config.readfp(open(args.config)) # Create a connection to CoreCommerce. cc_browser = cctools.CCBrowser( config.get("website", "base_url"), config.get("website", "username"), config.get("website", "password") ) # Fetch products list. products = cc_browser.get_products() # Sort products by category, product_name. products = sorted( products, key=cc_browser.product_key_by_cat_and_name ) if args.write_quant: logger.debug("Generating {}".format(args.quant_filename)) write_quantities(args.quant_filename, products) else: quantities = load_quantities(args.quant_filename) pdf_filename = args.pdf_filename logger.debug("Generating {}".format(pdf_filename)) generate_pdf(products, quantities, pdf_filename) logger.debug("Generation complete") return 0
def main(): """main""" default_config = os.path.join(os.path.dirname(os.path.abspath(__file__)), "cctools.cfg") now = datetime.datetime.now() default_xlsx_filename = now.strftime("%Y-%m-%d-WholesaleLineSheet.xlsx") arg_parser = argparse.ArgumentParser( description="Generates a wholesale line sheet.") arg_parser.add_argument( "--config", dest="config", metavar="FILE", default=default_config, help="configuration filename (default=%(default)s)") arg_parser.add_argument("--price-multiplier", type=float, metavar="M", help="retail price multiplier (default=1.0)") arg_parser.add_argument("--price-precision", type=float, metavar="P", default=0.01, help="precision of prices (default=%(default).2f)") arg_parser.add_argument( "--wholesale-fraction", type=float, metavar="F", default=0.5, help="wholesale price fraction (default=%(default).2f)") arg_parser.add_argument( "--valid-ndays", metavar="N", type=int, default=30, help="number of days prices are valid (default=%(default)i)") arg_parser.add_argument("--outfile", dest="xlsx_filename", metavar="FILE", default=default_xlsx_filename, help="output XLSX filename (default=%(default)s)") arg_parser.add_argument("--include-variants", action="store_true", default=False, help="add row for each product variant") arg_parser.add_argument("--exclude-sku", action="append", dest="exclude_skus", metavar="SKU", help="exclude SKU from output") arg_parser.add_argument("--verbose", action="store_true", default=False, help="display progress messages") # Parse command line arguments. args = arg_parser.parse_args() # Configure logging. logging.basicConfig( level=logging.INFO if args.verbose else logging.WARNING) logger = logging.getLogger() # Also log using notify-send if it is available. if notify_send_handler.NotifySendHandler.is_available(): logger.addHandler( notify_send_handler.NotifySendHandler( os.path.splitext(os.path.basename(__file__))[0])) # Read config file. config = ConfigParser.RawConfigParser() config.readfp(open(args.config)) # Handle the price multiplier. if args.price_multiplier is None: price_multiplier = get_optional_option(config, "wholesale_line_sheet", "price_multiplier") if price_multiplier is None: args.price_multiplier = 1.0 else: args.price_multiplier = float(price_multiplier) # Create a connection to CoreCommerce. cc_browser = cctools.CCBrowser(config.get("website", "base_url"), config.get("website", "username"), config.get("website", "password")) # Fetch products list. products = cc_browser.get_products() # Generate spreadsheet. logger.debug("Generating {}".format(args.xlsx_filename)) generate_xlsx(args, config, cc_browser, products) logger.debug("Generation complete") return 0
def main(): """main""" # Construct default filename of configuration file. default_config = os.path.join( os.path.dirname(os.path.abspath(__file__)), "cctools.cfg" ) arg_parser = argparse.ArgumentParser( description="Generates a price list from CoreCommerce data." ) arg_parser.add_argument( "--config", metavar="FILE", default=default_config, help="configuration filename (default=%(default)s)" ) arg_parser.add_argument( "--category", action="append", dest="categories", metavar="CAT", help="include category in output" ) arg_parser.add_argument( "--exclude-category", action="append", dest="exclude_categories", metavar="CAT", help="exclude category from output" ) arg_parser.add_argument( "--exclude-sku", action="append", dest="exclude_skus", metavar="SKU", help="exclude SKU from output" ) arg_parser.add_argument( "--pdf-file", metavar="PDF_FILE", default="PriceListRetailTaxInc.pdf", help="output PDF filename (default=%(default)s)" ) arg_parser.add_argument( "--add-sku", action="store_true", default=False, help="append SKU to product name" ) arg_parser.add_argument( "--add-teaser", action="store_true", default=False, help="add teaser line" ) arg_parser.add_argument( "--ncols", type=int, metavar="N", default=None, help="number of report columns (default=2)" ) arg_parser.add_argument( "--greybar-interval", type=int, metavar="N", default=2, help="greybar interval (default=%(default)i)" ) arg_parser.add_argument( "--discount", type=float, dest="discount_percent", metavar="PCT", default=30, help="discount in percent (default=%(default).0f)" ) arg_parser.add_argument( "--avg-tax", type=float, dest="avg_tax_percent", metavar="PCT", default=8.3, help="average sales tax rate in percent (default=%(default).2f)" ) arg_parser.add_argument( "--verbose", action="store_true", default=False, help="display progress messages" ) # Parse command line arguments. args = arg_parser.parse_args() if args.categories and args.exclude_categories: arg_parser.error("--category and --exclude-category specified") if args.ncols is None: if args.add_teaser: args.ncols = 1 else: args.ncols = 2 # Configure logging. logging.basicConfig( level=logging.INFO if args.verbose else logging.WARNING ) logger = logging.getLogger() # Also log using notify-send if it is available. if notify_send_handler.NotifySendHandler.is_available(): logger.addHandler( notify_send_handler.NotifySendHandler( os.path.splitext(os.path.basename(__file__))[0] ) ) # Read config file. config = ConfigParser.SafeConfigParser({ "body_fontsize": "12", "row_padding": "0" }) config.readfp(open(args.config)) # Create a connection to CoreCommerce. cc_browser = cctools.CCBrowser( config.get("website", "base_url"), config.get("website", "username"), config.get("website", "password") ) # Get product list. products = get_products(args, cc_browser) # Generate PDF file. logger.debug("Generating {}\n".format(os.path.abspath(args.pdf_file))) generate_pdf( args, config, cc_browser, products ) logger.debug("Generation complete") return 0