NovaBryan/EVE_Dump
Log | Files | 📦 下载最新源码 (.zip) | Refs | README

commonutils.py (1093B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\carbon\common\script\util\commonutils.py
      2 import re
      3 import blue
      4 from carbon.common.script.sys.serviceConst import ROLEMASK_ELEVATEDPLAYER
      5 from eveprefs import boot
      6 
      7 def IsFullLogging():
      8     return boot.role != 'client' or not blue.pyos.packaged or session.role & ROLEMASK_ELEVATEDPLAYER
      9 
     10 
     11 def GetAttrs(obj, *names):
     12     for name in names:
     13         obj = getattr(obj, name, None)
     14         if obj is None:
     15             return
     16 
     17     return obj
     18 
     19 
     20 def StripTags(s, ignoredTags = tuple(), stripOnly = tuple()):
     21     if not s or not isinstance(s, basestring):
     22         return s
     23     regex = '|'.join([ '</%s>|<%s>|<%s .*?>|<%s *=.*?>|<%s/>' % (tag,
     24      tag,
     25      tag,
     26      tag,
     27      tag) for tag in stripOnly or ignoredTags ])
     28     if stripOnly:
     29         return ''.join(re.split(regex, s))
     30     elif ignoredTags:
     31         for matchingTag in [ tag for tag in re.findall('<.*?>', s) if tag not in re.findall(regex, s) ]:
     32             s = s.replace(matchingTag, '')
     33 
     34         return s
     35     else:
     36         return ''.join(re.split('<.*?>', s))