# Path: common/util.py
# ANSI_BLUE = '\033[36m'
# ANSI_GREEN = '\033[32m'
# ANSI_RESET = '\033[0;0m'
# class Logger(object):
#   def __init__(self, color):
#   def __call__(self, msg, *args):
# def GetPackageDir():
# def GetUserDir():
# 
# Path: common/spy.py
# class Error(Exception):
# class UsageReporter(object):
# class NullUsageReporter(object):
#   def __init__(self, host_port):
#   def Send(self, msg):
#   def SendDict(self, d):
#   def SendRecord(self, event, d):
#   def Send(self, msg):
#   def SendDict(self, d):
#   def SendRecord(self, event, d):
# def _GetUsageConfig():
# def _ReadAddressFile(address_file=None):
# def GetClientFromConfig(address_file=None):


import getopt
import json
import os
import re
import socket
import subprocess
import sys
import time
import tnet
from common import util
from common import spy
# image/png, image/gif, etc. might be useful
#
# Also: aliases like htm, html, etc. are detected

def GetFileType(input_path):
  """
  Args:
    input_path: could be relative or absolute
  """
  basename = os.path.basename(input_path)

  # NOTE: Don't use os.path.splitext because it takes only the LAST extension.
  # We want "tar.gz", not "gz" it takes the LAST extension.  We want "tar.gz",
  # not "gz".

  i = basename.find('.')
  if i == -1:
    # e.g. 'Makefile'
    return basename
  else:
    # e.g. tar.gz, png
    return basename[i+1:]


# TODO: Move this to util/resources or something
# find rendering plugins, publishing plugins, etc.
# used in publish.py, xrender.py, handlers.py

class Resources(object):
  def __init__(self, package_dir=None):

# Path: common/util.py
# ANSI_BLUE = '\033[36m'
# ANSI_GREEN = '\033[32m'
# ANSI_RESET = '\033[0;0m'
# class Logger(object):
#   def __init__(self, color):
#   def __call__(self, msg, *args):
# def GetPackageDir():
# def GetUserDir():
# 
# Path: common/spy.py
# class Error(Exception):
# class UsageReporter(object):
# class NullUsageReporter(object):
#   def __init__(self, host_port):
#   def Send(self, msg):
#   def SendDict(self, d):
#   def SendRecord(self, event, d):
#   def Send(self, msg):
#   def SendDict(self, d):
#   def SendRecord(self, event, d):
# def _GetUsageConfig():
# def _ReadAddressFile(address_file=None):
# def GetClientFromConfig(address_file=None):


# Path: webpipe/xrender.py
import getopt
import json
import os
import re
import socket
import subprocess
import sys
import time
import tnet
from common import util
from common import spy

# image/png, image/gif, etc. might be useful
#
# Also: aliases like htm, html, etc. are detected

def GetFileType(input_path):
  """
  Args:
    input_path: could be relative or absolute
  """
  basename = os.path.basename(input_path)

  # NOTE: Don't use os.path.splitext because it takes only the LAST extension.
  # We want "tar.gz", not "gz" it takes the LAST extension.  We want "tar.gz",
  # not "gz".

  i = basename.find('.')
  if i == -1:
    # e.g. 'Makefile'
    return basename
  else:
    # e.g. tar.gz, png
    return basename[i+1:]


# TODO: Move this to util/resources or something
# find rendering plugins, publishing plugins, etc.
# used in publish.py, xrender.py, handlers.py

class Resources(object):
  def __init__(self, package_dir=None):

    self.package_dir = util.GetPackageDir()