original_docstring:  read a (small) text file from the baseline store 
docstring: read a (small) text file from the baseline store
docstring_tokens: read a ( small ) text file from the baseline store
code: def _read_baseline_file(self, tag, path):
          """ read a (small) text file from the baseline store """
          if self.baseline.startswith('s3://'):
              try:
                  # Try downloading from S3
                  return subprocess.check_output(['aws', 's3', 'cp', '/'.join([self.baseline, 'outstore-' + tag, path]), '-']).decode('utf-8')
              except subprocess.CalledProcessError:
                  # If that doesn't work, we may not have access.
                  # See if it's available over HTTP (which it won't be if it's our vg-data bucket).
                  toks = self.baseline[5:].split('/')
                  bname = toks[0]
                  keyname = '/{}/outstore-{}/{}'.format('/'.join(toks[1:]), tag, path)
                  
                  # Convert to a public HTTPS URL
                  url = 'https://{}.s3.amazonaws.com{}'.format(bname, keyname)
                  # And download it
  
                  try:
                      connection = urllib.request.urlopen(url)
                      return connection.read().decode('utf-8')
                  except urllib.error.HTTPError as e:
                      if e.code == 404 or e.code == 403:
                          # Baseline file doesn't yet exist, or isn't public.
                          # Give an empty string. Nonexistent things give 403 to
                          # prevent enumeration.
                          return ""
                      else:
                          # Something else is wrong
                          raise
          else:
              # Assume it's a raw path.
              with io.open(os.path.join(self.baseline, 'outstore-{}'.format(tag), path), 'r', encoding='utf8') as f:
                  return f.read()
code_tokens: def _read_baseline_file ( self , tag , path ) : if self . baseline . startswith ( 's3://' ) : try : return subprocess . check_output ( [ 'aws' , 's3' , 'cp' , '/' . join ( [ self . baseline , 'outstore-' + tag , path ] ) , '-' ] ) . decode ( 'utf-8' ) except subprocess . CalledProcessError : toks = self . baseline [ 5 : ] . split ( '/' ) bname = toks [ 0 ] keyname = '/{}/outstore-{}/{}' . format ( '/' . join ( toks [ 1 : ] ) , tag , path ) url = 'https://{}.s3.amazonaws.com{}' . format ( bname , keyname ) try : connection = urllib . request . urlopen ( url ) return connection . read ( ) . decode ( 'utf-8' ) except urllib . error . HTTPError as e : if e . code == 404 or e . code == 403 : return "" else : raise else : with io . open ( os . path . join ( self . baseline , 'outstore-{}' . format ( tag ) , path ) , 'r' , encoding = 'utf8' ) as f : return f . read ( )
short_docstring: read a (small) text file from the baseline store
short_docstring_tokens: read a ( small ) text file from the baseline store
comment: """ read a (small) text file from the baseline store """$SEP$# Try downloading from S3$SEP$# If that doesn't work, we may not have access.$SEP$# See if it's available over HTTP (which it won't be if it's our vg-data bucket).$SEP$# Convert to a public HTTPS URL$SEP$# And download it$SEP$# Baseline file doesn't yet exist, or isn't public.$SEP$# Give an empty string. Nonexistent things give 403 to$SEP$# prevent enumeration.$SEP$# Something else is wrong$SEP$# Assume it's a raw path.