为实现目标而工作的图书馆

aimslib的Python项目详细描述


艾姆斯里布

这是来自不同项目的重构,用于移动 从AIMS服务器提取信息到公共库中。它是建造和 在easyJet AIMS服务器上进行了测试。它可能需要适应与 AIMS服务器由其他航空公司运行。在

示例代码

importjsonimportsysfromaimslib.access.connectimportconnect,logoutfromaimslib.access.cacheimportTripCache,CrewlistCachefromaimslib.common.typesimportNoTripDetailsimportaimslib.access.brief_rosterasRoster#put your own values in hereCACHE_DIR="/SUITABLE/LOCATION/FOR/CACHE/"ECREW_LOGIN_PAGE="https://ECREW/LOGIN/PAGE"USERNAME="YOUR_USERNAME"PASSWORD="YOUR_PASSWORD"defheartbeat():sys.stderr.write('.')sys.stderr.flush()#connect to AIMSpost_func=connect(ECREW_LOGIN_PAGE,USERNAME,PASSWORD,heartbeat)#build a sparse duty list from the current brief roster and the two beforesparse_dutylist=[]forrosterinRoster.retrieve(post_func,-2):sparse_dutylist.extend(Roster.duties(Roster.parse(roster)))#build an expanded duty list using trip pagesexpanded_dutylist=[]trip_cache=TripCache(CACHE_DIR+"aimslib.tripcache",post_func)last_id=Nonefordutyinsorted(sparse_dutylist):ifduty.trip_id==last_id:continue#sparse_dutylist may contain duplicateslast_id=duty.trip_idifduty.startisNone:try:expanded_dutylist.extend(trip_cache.trip(duty.trip_id))exceptNoTripDetails:print("Trip details not found for: ",duty.trip_id,file=sys.stderr)else:expanded_dutylist.append(duty)trip_cache.store()#build crewlist mapcrew_cache=CrewlistCache(CACHE_DIR+"aimslib.clcache",post_func)crewlist_map={}fordutyinexpanded_dutylist:ifduty.sectors:forsectorinduty.sectors:ifnotsector.crewlist_id:continuecrewlist=crew_cache.crewlist(sector.crewlist_id)crewlist_map[sector.crewlist_id]=crewlistcrew_cache.store()#dump objects as jsonprint(json.dumps((expanded_dutylist,crewlist_map),default=lambdao:str(o),indent=2))#cleanuplogout(post_func)

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
virtualbox无法从java移动共享文件夹中的文件   java如何连接Android 4.3.5(GA)的apache HttpClient库?   片段中的java Recyclerview未立即显示警报对话框结果   javac(n,r)计算器程序不工作   java使用BooleanQuery还是编写更多索引?   如何在java中设置y/n循环?   java不兼容的通用通配符捕获   java如何在安卓xml中编写数据绑定时的三元操作条件   java如何使用FileDialog?   java如何创建单元测试来检测是否有人使用错误的编码编辑了文件?   java如何从唯一的字符串生成唯一的int?   java gradletomcatplugin:log4j:WARN找不到记录器的附加程序   java我的动态编程解决方案(Kefa和第一步)在codeforces中有什么问题?   java每天更新两个数据库,使它们都包含相同的有效数据集   java如何检查给定的时间是否在时间限制之间   java在单个json POST上保存父级和子级   java如何获取Solr字段类型