Skip to main content

Python API

About

A Python package of common EDI functions.

Install

To install this package use:

pip install MedatechUK.APY

Imports

Logging Class

A class to create log files.

from MedatechUK.mLog import mLog

log = mLog()
log.start( os.getcwd(), "DEBUG" )
log.logger.debug("Starting {}".format(__file__)) 

Config Class

A class for managing oData settings.

from MedatechUK.oDataConfig import Config

c = Config(	                 # Using this configuration
    env="wlnd" ,    	     # the Priority environment
    path=os.getcwd()    	 # the location of the config file
)

Command Line Arguments

A package of command line tools, including parsing the sys.argv function in Python.

progname.exe -arg value -arg2 "value two"
arg.byName(['arg','a']) = "value"
arg.byName(['arg2','a2']) = "value two"
arg.byName(['arg3','a3']) = None

Serial Class

A package for working with serial data.

See also: Serial object methods

from MedatechUK.Serial import SerialBase , SerialT , SerialF

# Load an Order from json file
with open('test.json', 'r') as the_file:        
    q = order(json=the_file)
    # Save to xml
    q.toFile('test2.xml', q.toXML, root="root")
	

APY Class

A class for handling HTTP Request/Response.

See Also: the http transport example

from MedatechUK.apy import Request , Response

def ProcessRequest(request) :
    log = mLog()
    try:
        q = order(**request.data)            
        q.toPri(
            Config(
                env=request.environment , 
                path=os.getcwd()
            ) , 
            q.toFlatOdata, 
            request=request 
        )        
    
    except Exception as e:
        log.logger.critical(str(e))
        exc_type, exc_obj, exc_tb = sys.exc_info()
        fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]        
        request.response.Status = 500
        request.response.Message = "Internal Server Error"
        request.response.data ={ "error" :
            {
                "type": exc_type,
                "message": str(e),
                "script": fname,
                "line": exc_tb.tb_lineno
            }
        } 

AppSvc Class

This package contains a debug-able inheritable Windows Service.

class MySVC(AppSvc):    
    _svc_name_ = "testSVC"
    _svc_display_name_ = "Test Service"    

    def __init__(self , args):    
        self.Main = MySVC.main   
        self.Init = MySVC.init   
        self.Folder = Path(__file__).parent         
        AppSvc.__init__(self , args)

    def init(self):
        if self.debuginit: debugpy.breakpoint() # -debug init
        # Do servce setup

    def main(self):       
        if self.debug: debugpy.breakpoint # -debug          
        
        # Main service    
        self.log.logger.debug(self.clArg.byName(['env','e']))

if __name__ == '__main__':    
    win32serviceutil.HandleCommandLine(MySVC)    

EPDM Class

A package for working with EPDM (Solid Works) serial data.

See Also: Making the EPDM example executable.

See Also: Running the EPDM executable from a service

from MedatechUK.epdm import xmlTransactions

# Load an EPDM file.
try:
    with open('example.xml', 'r') as the_file:        
        q = xmlTransactions(_xml=the_file)
        for t in q.transactions:
            recurse(t.document)

except Exception as e:
    log.logger.critical(str(e))
	

Metadata

Release files for MedatechUK.APY 0.0.27

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for MedatechUK.APY 0.0.27
File Size Uploaded
medatechuk_apy-0.0.27.tar.gz 40.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for MedatechUK.APY 0.0.27
File Interpreter ABI Platform
MedatechUK.APY-0.0.27-py3-none-any.whl Python 3 none any Details

Total release size: 81.9 kB

Release files / medatechuk_apy-0.0.27.tar.gz

Download URL medatechuk_apy-0.0.27.tar.gz
Size 40.5 kB
Tags Source
SHA-256 checksum
How to use checksums
45faac1dcdc48cb3c3effd4e4f0729081df3898856be907e0394d7483b7b3c7b
BLAKE2b-256 checksum
How to use checksums
9e663ab2f75ec4966063c3d0dc8fa3824e784b13be5e42bcd7e9c5211856c86b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.3

Release files / MedatechUK.APY-0.0.27-py3-none-any.whl

Download URL MedatechUK.APY-0.0.27-py3-none-any.whl
Size 41.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8f54e64fe9a1f7e8c21b114fab5d65d2b4f60f5e76864b1aa91bacf90bf6df72
BLAKE2b-256 checksum
How to use checksums
8a7b18ecec48761bc6cfe9c8cb0ab96775a1adcb5fa290cdaf0ad6fcbe1fe73a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.0.27 This release

2 release files

0.0.26

2 release files

0.0.25

2 release files

0.0.24

2 release files

0.0.23

2 release files

0.0.22

2 release files

0.0.21

2 release files

0.0.20

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page