def save_suppliers(path=None, customer_idurl=None): """ Write current suppliers list on the disk, ``path`` is a file path to save. """ if not customer_idurl: customer_idurl = my_id.getLocalID() customer_idurl = strng.to_bin(customer_idurl.strip()) customer_id = global_id.UrlToGlobalID(customer_idurl) if path is None: path = os.path.join( settings.SuppliersDir(), customer_id, 'supplierids', ) lst = suppliers(customer_idurl=customer_idurl) lst = list(map(strng.to_text, lst)) if not os.path.exists(os.path.dirname(path)): bpio._dirs_make(os.path.dirname(path)) bpio._write_list(path, lst) if _Debug: lg.out( _DebugLevel, 'contactsdb.save_suppliers for customer [%s]:\n%r' % ( customer_id, lst, )) return True
def save_customers(path=None): """ Write current customers list on the disk, ``path`` is a file path to save. """ if path is None: path = settings.CustomerIDsFilename() bpio._write_list(path, customers())
def save_customers(path=None, save_meta_info=False): """ Write current customers list on the disk, ``path`` is a file path to save. """ global _CustomersMetaInfo if path is None: path = settings.CustomerIDsFilename() lst = customers() lst = list(map(strng.to_text, lst)) bpio._write_list(path, lst) if save_meta_info: json_info = id_url.to_bin_dict(_CustomersMetaInfo) local_fs.WriteTextFile( settings.CustomersMetaInfoFilename(), jsn.dumps( json_info, indent=2, sort_keys=True, keys_to_text=True, )) if _Debug: lg.out( _DebugLevel, 'contactsdb.save_customers save_meta_info=%r : %r' % ( save_meta_info, lst, ))
def save_correspondents(path=None): """ Write current correspondents list on the disk, ``path`` is a file path to save. """ if path is None: path = settings.CorrespondentIDsFilename() bpio._write_list(path, map(lambda t: "%s %s" % t, correspondents()))
def save_correspondents(path=None): """ Write current correspondents list on the disk, ``path`` is a file path to save. """ if path is None: path = settings.CorrespondentIDsFilename() lst = ["%s %s" % (strng.to_text(t[0]), strng.to_text(t[1]),) for t in correspondents()] bpio._write_list(path, lst)
def save_suppliers(path=None, customer_idurl=None): """ Write current suppliers list on the disk, ``path`` is a file path to save. """ if path is None: path = settings.SupplierIDsFilename() if customer_idurl is not None: path += ('_%s' % global_id.UrlToGlobalID(customer_idurl)) bpio._write_list(path, suppliers())
def save_suppliers(path=None, customer_idurl=None): """ Write current suppliers list on the disk, ``path`` is a file path to save. """ if not customer_idurl: customer_idurl = my_id.getLocalID() if path is None: path = os.path.join( settings.SuppliersDir(), global_id.UrlToGlobalID(customer_idurl), 'supplierids', ) bpio._write_list(path, suppliers(customer_idurl=customer_idurl)) return True
def save_customers(path=None, save_meta_info=False): """ Write current customers list on the disk, ``path`` is a file path to save. """ global _CustomersMetaInfo if path is None: path = settings.CustomerIDsFilename() lst = customers() lst = list(map(strng.to_text, lst)) bpio._write_list(path, lst) if save_meta_info: local_fs.WriteTextFile(settings.CustomersMetaInfoFilename(), jsn.dumps(_CustomersMetaInfo)) if _Debug: lg.out(_DebugLevel, 'contactsdb.save_customers : %r' % lst)