Ejemplo n.º 1
0
def delete_path(path, obj):
    """Delete a dotted path from object, assuming each level is a dict"""
    parts = path.split('.')
    for p in parts[:-1]:
        obj = obj[p]
    if parts[-1] in obj:
        del obj[parts[-1]]
Ejemplo n.º 2
0
 def __init__(self, source, path, mask=None, category=None, extra_data=None):
     self.source = source
     self.path = path
     self.mask = mask
     self.category = category
     self.name = path.split("/")[-1]
     self.extra_data = extra_data
     self.process_results = {}
Ejemplo n.º 3
0
    def GetRegistryKeyFromPath(project, path):
        """
      Given a registry key path like HKLM\Software\Microsoft return
      the corresponding registry key for the project.
      """
        def scanLeft(func, state, items):
            for i in items:
                state = func(state, i)
                yield state

        pathElems = path.split('\\')
        # Given the input HKLM\Software\Microsoft this would generate
        # [HKLM, HKLM\Software, HKLM\Software\Microsoft] so that we can
        # iterate over it looking for the corresponding key.
        fullPath = scanLeft(lambda x, y: x + '\\' + y, '', pathElems)
        # Strip off leading \
        fullPath = map(lambda x: x.lstrip('\\'), fullPath)

        # Start search at project registry root.
        regKey = project.registry

        for p in fullPath:
            for i in regKey.subkeys:
                if i.path == p:
                    # Continue search by rebasing root onto the new key.
                    regKey = i
                    break
            else:
                # The next subkey was not found.
                return None

        # Check for the full path at the end to ensure we terminated at
        # the right place.
        if regKey.path == path:
            return regKey
        else:
            return None
Ejemplo n.º 4
0
   def GetRegistryKeyFromPath(project, path):
      """
      Given a registry key path like HKLM\Software\Microsoft return
      the corresponding registry key for the project.
      """
      def scanLeft(func, state, items):
         for i in items:
            state = func(state, i)
            yield state

      pathElems = path.split('\\')
      # Given the input HKLM\Software\Microsoft this would generate
      # [HKLM, HKLM\Software, HKLM\Software\Microsoft] so that we can
      # iterate over it looking for the corresponding key.
      fullPath = scanLeft(lambda x, y: x + '\\' + y, '', pathElems)
      # Strip off leading \
      fullPath = map(lambda x: x.lstrip('\\'), fullPath)

      # Start search at project registry root.
      regKey = project.registry

      for p in fullPath:
         for i in regKey.subkeys:
            if i.path == p:
               # Continue search by rebasing root onto the new key.
               regKey = i
               break
         else:
            # The next subkey was not found.
            return None

      # Check for the full path at the end to ensure we terminated at
      # the right place.
      if regKey.path == path:
         return regKey
      else:
         return None
Ejemplo n.º 5
0
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#

from path import path
import codecs
import os

csv2txt = path.getcwd().files("*.CSV")
for path in csv2txt:
	print(path)
	parts = path.split('.')
	new_name = format(parts[0]) + ".txt"
	os.rename(path, new_name)

# processes all files in the working folder starting with 20, change path in accordance to your needs
filepaths = path.getcwd().files("20*.txt")

# list of conditions, change in accordance to your needs
code_eventtype = "14"
code_countrycode = ["AV", "AC", "AA", "BF", "BB", "VI", "CJ", "CU" ,"DO", "DR", "GJ", "GP", "HA", "JM", "MB", "MH", "RQ", "SC", "ST", "RN", "VC", "TD", "TK", "VQ", "BH", "CS", "ES", "GT", "HO", "MX", "NU", "PM", "AR", "BL", "BR", "CI", "CO", "EC", "FK", "FG", "GY", "PA", "PE", "NS", "UY", "VE", "BD" ,"CA", "GL", "SB", "US"]
minimum_coverage = 2
code_allowed_actors = ["ABW", "AMN", "ANT", "ARG", "ASM", "ATG", "ATH", "BLZ", "BMU", "BOL", "BRA", "BRB", "BUS", "CAN", "CHL", "CHR", "CMN", "C*K", "COL", "CPA", "CPC", "CPT", "CRB", "CRI", "CTH", "CUB", "CVL", "DMA", "DOM", "DOX", "ECD", "ECU", "EDU", "ELI", "FAO", "FID", "FLK", "GLP", "GRD", "GRL", "GRP", "GTM", "GUF", "GUY", "HCH", "HCR", "HLH", "HND", "HRW", "HTI", "ICC", "ICG", "ICJ", "ICO", "IGC", "IGO", "IHF", "ILO", "INT", "IOM", "IRC", "JAM", "JEW", "JHW", "JUD", "KID", "LAB", "LAM", "LCA", "MED", "MEX", "MOD", "MRX", "MSF", "MSR", "MTQ", "NGM", "NGO", "NMR", "NON", "OAS", "OPC", "OPP", "PAN", "PER", "PRI", "PRO", "PRY", "RAD", "REB", "REF", "REL", "REU", "SAM", "SLV", "SUR", "UAF", "URY", "USA", "VCT", "VEN", "VGB", "VIR", "WCT", "WEF", "WFP", "WHO", "WSM", "XFM"]
code_excluded_actors =["GOV", "COP", "SPY", "MIL", "CRM", "NGO", "RAD", "LEG", "IGO", "JUD", "REB", "SEP", "MNC", "ELI", "IMG", "UAF"]

gdelt_header = "GLOBALEVENTID	SQLDATE	MonthYear	Year	FractionDate	Actor1Code	Actor1Name	Actor1CountryCode	Actor1KnownGroupCode	Actor1EthnicCode	Actor1Religion1Code	Actor1Religion2Code	Actor1Type1Code	Actor1Type2Code	Actor1Type3Code	Actor2Code	Actor2Name	Actor2CountryCode	Actor2KnownGroupCode	Actor2EthnicCode	Actor2Religion1Code	Actor2Religion2Code	Actor2Type1Code	Actor2Type2Code	Actor2Type3Code	IsRootEvent	EventCode	EventBaseCode	EventRootCode	QuadClass	GoldsteinScale	NumMentions	NumSources	NumArticles	AvgTone	Actor1Geo_Type	Actor1Geo_FullName	Actor1Geo_CountryCode	Actor1Geo_ADM1Code	Actor1Geo_Lat	Actor1Geo_Long	Actor1Geo_FeatureID	Actor2Geo_Type	Actor2Geo_FullName	Actor2Geo_CountryCode	Actor2Geo_ADM1Code	Actor2Geo_Lat	Actor2Geo_Long	Actor2Geo_FeatureID	ActionGeo_Type	ActionGeo_FullName	ActionGeo_CountryCode	ActionGeo_ADM1Code	ActionGeo_Lat	ActionGeo_Long	ActionGeo_FeatureID	DATEADDED SOURCE"
subset_output = open("subset.txt", "w", encoding="utf-8")
Ejemplo n.º 6
0
# but we may want to use a 'preview' instance of LMS as in v1
PREVIEW_LMS_BASE = ''  # Sudio will build preview address like this //PREVIEW_LMS_BASE + LMS_BASE to/course...

LOCAL_LOGLEVEL = 'INFO'
LOGGING_ENV = 'sandbox'
LOG_DIR = '/edx/var/logs/edx'

### Max size of asset uploads to GridFS
MAX_ASSET_UPLOAD_FILE_SIZE_IN_MB = 30

SEGMENT_IO_LMS = True
PAID_COURSE_REGISTRATION_CURRENCY = ["usd", "$"]
SEGMENT_IO_LMS = True

# Locale path
LOCALIZED_APPS = sorted([path.split("/")[-2] for path in glob(FUN_BASE_ROOT / "*/locale")])
LOCALE_PATHS = tuple(
    [FUN_BASE_ROOT / app / "locale" for app in LOCALIZED_APPS] +
    [
        BASE_ROOT / 'themes/fun/locale',
        BASE_ROOT / 'edx-platform/conf/locale',
        BASE_ROOT / 'venvs/edxapp/lib/python2.7/site-packages/django_countries/locale',    # this should not be required
    ]
)

# Custom password policy will be activated by FEATURES['ENFORCE_PASSWORD_POLICY'] = True
PASSWORD_MIN_LENGTH = 8
PASSWORD_MAX_LENGTH = 30
PASSWORD_COMPLEXITY = {
      'UPPER' : 1,
      'LOWER' : 1,
 def limit_depth(path):
     parts = path.split("/")
     if len(parts) <= 2:
         return path
     else:
         return "/".join(parts[:2])
Ejemplo n.º 8
0
	def shell_quote(self,path):
   		return "\'".join(path.split("'"))
Ejemplo n.º 9
0
def profile_for_path(path):
    if not path.startswith("unison:"):
        return None
    return path.split(":")[1]