text:
/**
 * SliceManagerImplTest.java
 * (C) 2013,2015, Hitachi, Ltd.
 */
package org.o3project.mlo.server.impl.logic;

import static org.junit.Assert.*;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.o3project.mlo.server.dto.RestifRequestDto;
import org.o3project.mlo.server.dto.RestifResponseDto;
import org.o3project.mlo.server.impl.logic.ConfigProviderImpl;
import org.o3project.mlo.server.impl.logic.DebugRestifChecker;
import org.o3project.mlo.server.impl.logic.EquipmentConfiguratorNullImpl;
import org.o3project.mlo.server.impl.logic.SerdesImpl;
import org.o3project.mlo.server.impl.logic.SliceManager;
import org.o3project.mlo.server.logic.ApiCallException;
import org.o3project.mlo.server.logic.DbAccessException;
import org.o3project.mlo.server.logic.InternalException;
import org.o3project.mlo.server.logic.MloException;
import org.o3project.mlo.server.logic.NbiConstants;
import org.o3project.mlo.server.logic.OtherException;
import org.o3project.mlo.server.logic.Serdes;
import org.o3project.mlo.server.logic.TimeOutException;
import org.o3project.mlo.server.logic.TopologyRepository;

/**
 * SliceManagerImplTest
 *
 */
public class SliceManagerImplTest implements NbiConstants {

	private static final String DATA_PATH = "src/test/resources/org/o3project/mlo/server/logic/data/hitachi";

	private final Serdes serdes = new SerdesImpl();
	private SliceManager obj;
	private EquipmentConfiguratorNullImpl equConf;

	/**
	 * @throws java.lang.Exception
	 */
	@Before
	public void setUp() throws Exception {
		File propFile = new File("src/test/resources/", "test.mlo-srv.properties");
		ConfigProviderImpl configProvider = ConfigProviderImplTest.createConfigProviderImpl(propFile.getAbsolutePath());

		TopologyRepository topologyRepositoryDefaultImpl = TopologyRepositoryDefaultImplTest.createObjLoaded(configProvider);

		DebugRestifChecker debugRestifChecker = new DebugRestifChecker();
		debugRestifChecker.setConfigProvider(configProvider);

		obj = new SliceManager();
		obj.setTopologyRepository(topologyRepositoryDefaultImpl);
		obj.setDebugRestifChecker(debugRestifChecker);
		equConf = new EquipmentConfiguratorNullImpl();
	}

	/**
	 * @throws java.lang.Exception
	 */
	@After
	public void tearDown() throws Exception {
		obj = null;
		equConf = null;
	}

	/**
	 * Test method for {@link org.o3project.mlo.server.impl.logic.SliceManager#createSlice(org.o3project.mlo.server.dto.RestifRequestDto)}.
	 */
	@Test
	public void testCreateSlice_n_001() throws Throwable {
		RestifRequestDto reqDto = null;
		RestifResponseDto resDto = null;
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.n.001.create.req.xml");
		resDto = obj.createSlice(reqDto, equConf);
		assertTrue(DtoTestUtils.isSameResAsXml(serdes, resDto, DATA_PATH, "dummy.n.001.create.res.xml"));
	}

	/**
	 * Test method for {@link org.o3project.mlo.server.impl.logic.SliceManager#createSlice(org.o3project.mlo.server.dto.RestifRequestDto)}.
	 */
	@Test
	public void testCreateSlice_a_already() throws Throwable {
		RestifRequestDto reqDto = null;
		RestifResponseDto resDto = null;
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.n.001.create.req.xml");
		resDto = obj.createSlice(reqDto, equConf);
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.n.001.create.req.xml");
		resDto = null;
		try {
			resDto = obj.createSlice(reqDto, equConf);
			fail();
		} catch (ApiCallException e) {
			assertNull(resDto);
			assertEquals("AlreadyCreated", e.getMessage());
			assertEquals("sliceA", e.getSliceName());
			assertEquals("00000001", e.getSliceId());
		}
	}

	/**
	 * Test method for {@link org.o3project.mlo.server.impl.logic.SliceManager#createSlice(org.o3project.mlo.server.dto.RestifRequestDto)}.
	 */
	@Test
	public void testCreateSlice_a_NoFlow() throws Throwable {
		RestifRequestDto reqDto = null;
		RestifResponseDto resDto = null;
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.a.NoFlow.create.req.xml");
		try {
			resDto = obj.createSlice(reqDto, equConf);
			fail();
		} catch (OtherException e) {
			assertNull(resDto);
			assertEquals("NoResource/FlowName=flow2", e.getMessage());
			assertEquals("sliceA", e.getSliceName());
			assertEquals("1", e.getSliceId());
		}
	}

	/**
	 * Test method for {@link org.o3project.mlo.server.impl.logic.SliceManager#updateSlice(org.o3project.mlo.server.dto.RestifRequestDto)}.
	 */
	@Test
	public void testUpdateSlice_add_n_001() throws Throwable {
		RestifRequestDto reqDto = null;
		RestifResponseDto resDto = null;
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.n.001.create.req.xml");
		resDto = obj.createSlice(reqDto, equConf);
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.n.001.update.add.req.xml");
		resDto = obj.updateSlice(reqDto, equConf);
		assertTrue(DtoTestUtils.isSameResAsXml(serdes, resDto, DATA_PATH, "dummy.n.001.update.add.res.xml"));
	}

	/**
	 * Test method for {@link org.o3project.mlo.server.impl.logic.SliceManager#updateSlice(org.o3project.mlo.server.dto.RestifRequestDto)}.
	 */
	@Test
	public void testUpdateSlice_mod_n_001() throws Throwable {
		RestifRequestDto reqDto = null;
		RestifResponseDto resDto = null;
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.n.001.create.req.xml");
		resDto = obj.createSlice(reqDto, equConf);
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.n.001.update.mod.req.xml");
		resDto = obj.updateSlice(reqDto, equConf);
		assertTrue(DtoTestUtils.isSameResAsXml(serdes, resDto, DATA_PATH, "dummy.n.001.update.mod.res.xml"));
	}

	/**
	 * Test method for {@link org.o3project.mlo.server.impl.logic.SliceManager#updateSlice(org.o3project.mlo.server.dto.RestifRequestDto)}.
	 */
	@Test
	public void testUpdateSlice_del_n_001() throws Throwable {
		RestifRequestDto reqDto = null;
		RestifResponseDto resDto = null;
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.n.001.create.req.xml");
		resDto = obj.createSlice(reqDto, equConf);
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.n.001.update.del.req.xml");
		resDto = obj.updateSlice(reqDto, equConf);
		assertTrue(DtoTestUtils.isSameResAsXml(serdes, resDto, DATA_PATH, "dummy.n.001.update.del.res.xml"));
	}

	/**
	 * Test method for {@link org.o3project.mlo.server.impl.logic.SliceManager#deleteSlice(org.o3project.mlo.server.dto.RestifRequestDto)}.
	 */
	@Test
	public void testDeleteSlice_n_001() throws Throwable {
		RestifRequestDto reqDto = null;
		RestifResponseDto resDto = null;
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.n.001.create.req.xml");
		resDto = obj.createSlice(reqDto, equConf);
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.n.001.delete.req.xml");
		resDto = obj.deleteSlice(reqDto, equConf);
		assertTrue(DtoTestUtils.isSameResAsXml(serdes, resDto, DATA_PATH, "dummy.n.001.delete.res.xml"));
	}

	/**
	 * Test method for {@link org.o3project.mlo.server.impl.logic.SliceManager#deleteSlice(org.o3project.mlo.server.dto.RestifRequestDto)}.
	 */
	@Test
	public void testDeleteSlice_a_already() throws Throwable {
		RestifRequestDto reqDto = null;
		RestifResponseDto resDto = null;
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.n.001.delete.req.xml");
		try {
			resDto = obj.deleteSlice(reqDto, equConf);
			fail();
		} catch (ApiCallException e) {
			assertEquals(null, resDto);
			assertEquals("AlreadyDeleted", e.getMessage());
			assertEquals(null, e.getSliceId());
			assertEquals(null, e.getSliceName());
		}
	}

	/**
	 * Test method for {@link org.o3project.mlo.server.impl.logic.SliceManager#readSlice(org.o3project.mlo.server.dto.RestifRequestDto)}.
	 */
	@Test
	public void testReadSlice_n_001() throws Throwable {
		RestifRequestDto reqDto = null;
		RestifResponseDto resDto = null;
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.n.001.create.req.xml");
		resDto = obj.createSlice(reqDto, equConf);
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.n.001.read.req.xml");
		resDto = obj.readSlice(reqDto);
		assertTrue(DtoTestUtils.isSameResAsXml(serdes, resDto, DATA_PATH, "dummy.n.001.read.res.xml"));
	}

	/**
	 * Test method for {@link org.o3project.mlo.server.impl.logic.SliceManager#updateSlice(org.o3project.mlo.server.dto.RestifRequestDto)}.
	 */
	@Test
	public void testUpdateSlice_add_n_002() throws Throwable {
		RestifRequestDto reqDto = null;
		RestifResponseDto resDto = null;

		// create
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.n.002.create.req.xml");
		resDto = obj.createSlice(reqDto, equConf);
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.n.002.read.req.xml");
		resDto = obj.readSlice(reqDto);
		assertTrue(DtoTestUtils.isSameResAsXml(serdes, resDto, DATA_PATH, "dummy.n.002.create.read.res.xml"));

		// update.add
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.n.002.update.add.req.xml");
		resDto = obj.updateSlice(reqDto, equConf);
		assertTrue(DtoTestUtils.isSameResAsXml(serdes, resDto, DATA_PATH, "dummy.n.002.update.add.res.xml"));
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.n.002.read.req.xml");
		resDto = obj.readSlice(reqDto);
		assertTrue(DtoTestUtils.isSameResAsXml(serdes, resDto, DATA_PATH, "dummy.n.002.update.add.read.res.xml"));
	}

	/**
	 * Test method for {@link org.o3project.mlo.server.impl.logic.SliceManager#updateSlice(org.o3project.mlo.server.dto.RestifRequestDto)}.
	 */
	@Test
	public void testUpdateSlice_mod_n_002() throws Throwable {
		RestifRequestDto reqDto = null;
		RestifResponseDto resDto = null;

		// create
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.n.002.create.req.xml");
		resDto = obj.createSlice(reqDto, equConf);
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.n.002.read.req.xml");
		resDto = obj.readSlice(reqDto);
		assertTrue(DtoTestUtils.isSameResAsXml(serdes, resDto, DATA_PATH, "dummy.n.002.create.read.res.xml"));

		// update.mod
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.n.002.update.mod.req.xml");
		resDto = obj.updateSlice(reqDto, equConf);
		assertTrue(DtoTestUtils.isSameResAsXml(serdes, resDto, DATA_PATH, "dummy.n.002.update.mod.res.xml"));
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.n.002.update.mod.read.req.xml");
		resDto = obj.readSlice(reqDto);
		assertTrue(DtoTestUtils.isSameResAsXml(serdes, resDto, DATA_PATH, "dummy.n.002.update.mod.read.res.xml"));
	}

	/**
	 * Test method for {@link org.o3project.mlo.server.impl.logic.SliceManager#updateSlice(org.o3project.mlo.server.dto.RestifRequestDto)}.
	 */
	@Test
	public void testOperateSlice_mod_n_003() throws Throwable {
		RestifRequestDto reqDto = null;
		RestifResponseDto resDto = null;

		// create
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.n.003.01.create.req.xml");
		resDto = obj.createSlice(reqDto, equConf);
		assertTrue(DtoTestUtils.isSameResAsXml(serdes, resDto, DATA_PATH, "dummy.n.003.01.create.res.xml"));
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.n.003.read.00000001.req.xml");
		resDto = obj.readSlice(reqDto);
		assertTrue(DtoTestUtils.isSameResAsXml(serdes, resDto, DATA_PATH, "dummy.n.003.02.read.00000001.res.xml"));

		// update.add
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.n.003.03.update.add.req.xml");
		resDto = obj.updateSlice(reqDto, equConf);
		assertTrue(DtoTestUtils.isSameResAsXml(serdes, resDto, DATA_PATH, "dummy.n.003.03.update.add.res.xml"));
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.n.003.read.00000001.req.xml");
		resDto = obj.readSlice(reqDto);
		assertTrue(DtoTestUtils.isSameResAsXml(serdes, resDto, DATA_PATH, "dummy.n.003.04.read.00000001.res.xml"));

		// create
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.n.003.05.create.req.xml");
		resDto = obj.createSlice(reqDto, equConf);
		assertTrue(DtoTestUtils.isSameResAsXml(serdes, resDto, DATA_PATH, "dummy.n.003.05.create.res.xml"));
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.n.003.read.00000002.req.xml");
		resDto = obj.readSlice(reqDto);
		assertTrue(DtoTestUtils.isSameResAsXml(serdes, resDto, DATA_PATH, "dummy.n.003.06.read.00000002.res.xml"));

		// update.mod
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.n.003.07.update.mod.req.xml");
		resDto = obj.updateSlice(reqDto, equConf);
		assertTrue(DtoTestUtils.isSameResAsXml(serdes, resDto, DATA_PATH, "dummy.n.003.07.update.mod.res.xml"));
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.n.003.read.00000001.req.xml");
		resDto = obj.readSlice(reqDto);
		assertTrue(DtoTestUtils.isSameResAsXml(serdes, resDto, DATA_PATH, "dummy.n.003.08.read.00000001.res.xml"));

		// update.del
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.n.003.09.update.del.req.xml");
		resDto = obj.updateSlice(reqDto, equConf);
		assertTrue(DtoTestUtils.isSameResAsXml(serdes, resDto, DATA_PATH, "dummy.n.003.09.update.del.res.xml"));
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.n.003.read.00000001.req.xml");
		resDto = obj.readSlice(reqDto);
		assertTrue(DtoTestUtils.isSameResAsXml(serdes, resDto, DATA_PATH, "dummy.n.003.10.read.00000001.res.xml"));

		// delete
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.n.003.11.delete.req.xml");
		resDto = obj.deleteSlice(reqDto, equConf);
		assertTrue(DtoTestUtils.isSameResAsXml(serdes, resDto, DATA_PATH, "dummy.n.003.11.delete.res.xml"));
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.n.003.read.00000001.req.xml");
		try {
			resDto = null;
			resDto = obj.readSlice(reqDto);
		} catch (ApiCallException e) {
			assertEquals(null, resDto);
			assertEquals("NoData", e.getMessage());
		}
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.n.003.read.00000002.req.xml");
		resDto = obj.readSlice(reqDto);
		assertTrue(DtoTestUtils.isSameResAsXml(serdes, resDto, DATA_PATH, "dummy.n.003.12.read.00000002.res.xml"));
	}

	/**
	 * Test method for {@link org.o3project.mlo.server.impl.logic.SliceManager#updateSlice(org.o3project.mlo.server.dto.RestifRequestDto)}.
	 */
	@Test
	public void testGetSlices_n_003() throws Throwable {
		RestifRequestDto reqDto = null;
		RestifResponseDto resDto = null;

		// create
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.n.003.01.create.req.xml");
		resDto = obj.createSlice(reqDto, equConf);
		assertTrue(DtoTestUtils.isSameResAsXml(serdes, resDto, DATA_PATH, "dummy.n.003.01.create.res.xml"));
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.n.003.read.00000001.req.xml");
		resDto = obj.readSlice(reqDto);
		assertTrue(DtoTestUtils.isSameResAsXml(serdes, resDto, DATA_PATH, "dummy.n.003.02.read.00000001.res.xml"));

		// update.add
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.n.003.03.update.add.req.xml");
		resDto = obj.updateSlice(reqDto, equConf);
		assertTrue(DtoTestUtils.isSameResAsXml(serdes, resDto, DATA_PATH, "dummy.n.003.03.update.add.res.xml"));
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.n.003.read.00000001.req.xml");
		resDto = obj.readSlice(reqDto);
		assertTrue(DtoTestUtils.isSameResAsXml(serdes, resDto, DATA_PATH, "dummy.n.003.04.read.00000001.res.xml"));

		// create
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.n.003.05.create.req.xml");
		resDto = obj.createSlice(reqDto, equConf);
		assertTrue(DtoTestUtils.isSameResAsXml(serdes, resDto, DATA_PATH, "dummy.n.003.05.create.res.xml"));
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.n.003.read.00000002.req.xml");
		resDto = obj.readSlice(reqDto);
		assertTrue(DtoTestUtils.isSameResAsXml(serdes, resDto, DATA_PATH, "dummy.n.003.06.read.00000002.res.xml"));

		// getSlices
		Map<String, String> paramMap = new HashMap<String, String>();
		paramMap.put(REQPARAM_KEY_OWNER, "demoApl");
		resDto = obj.getSlices(paramMap);
		assertTrue(DtoTestUtils.isSameResAsXml(serdes, resDto, DATA_PATH, "dummy.n.003.getSlices.res.xml"));
	}

	/**
	 * Test method for {@link org.o3project.mlo.server.impl.logic.SliceManager#createSlice(org.o3project.mlo.server.dto.RestifRequestDto)}.
	 */
	@Test
	public void testCreateSlice_a_CreateAPICallError() throws Throwable {
		RestifRequestDto reqDto = null;
		RestifResponseDto resDto = null;
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.a.CreateAPICallError.create.req.xml");
		try {
			resDto = obj.createSlice(reqDto, equConf);
			fail();
		} catch (MloException e) {
			assertTrue(e instanceof ApiCallException);
			assertEquals(null, resDto);
		}
	}

	/**
	 * Test method for {@link org.o3project.mlo.server.impl.logic.SliceManager#deleteSlice(org.o3project.mlo.server.dto.RestifRequestDto)}.
	 */
	@Test
	public void testDeleteSlice_a_DeleteInternalError() throws Throwable {
		RestifRequestDto reqDto = null;
		RestifResponseDto resDto = null;

		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.a.DeleteInternalError.create.req.xml");
		resDto = obj.createSlice(reqDto, equConf);

		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.n.001.delete.req.xml");
		resDto = null;
		try {
			resDto = obj.deleteSlice(reqDto, equConf);
			fail();
		} catch (MloException e) {
			assertTrue(e instanceof InternalException);
			assertEquals(null, resDto);
		}
	}

	/**
	 * Test method for {@link org.o3project.mlo.server.impl.logic.SliceManager#createSlice(org.o3project.mlo.server.dto.RestifRequestDto)}.
	 */
	@Test
	public void testCreateSlice_a_DebugOff_CreateAPICallError() throws Throwable {
		RestifRequestDto reqDto = null;
		RestifResponseDto resDto = null;

		setDebugOff();

		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.a.CreateAPICallError.create.req.xml");
		resDto = obj.createSlice(reqDto, equConf);
		assertNotNull(resDto);
	}

	/**
	 * Test method for {@link org.o3project.mlo.server.impl.logic.SliceManager#createSlice(org.o3project.mlo.server.dto.RestifRequestDto)}.
	 */
	@Test
	public void testCreateSlice_a_BeforeCreateToggledTimeOutError() throws Throwable {
		RestifRequestDto reqDto = null;
		RestifResponseDto resDto = null;
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.a.BeforeCreateToggledTimeOutError.create.req.xml");
		try {
			resDto = obj.createSlice(reqDto, equConf);
			fail();
		} catch (MloException e) {
			assertTrue(e instanceof TimeOutException);
			assertEquals(null, resDto);
		}

		resDto = obj.createSlice(reqDto, equConf);
		assertNotNull(resDto);

		resDto = null;
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.n.001.delete.req.xml");
		resDto = obj.deleteSlice(reqDto, equConf);
		assertNotNull(resDto);
	}

	/**
	 * Test method for {@link org.o3project.mlo.server.impl.logic.SliceManager#createSlice(org.o3project.mlo.server.dto.RestifRequestDto)}.
	 */
	@Test
	public void testCreateSlice_a_DebugOff_BeforeCreateToggledTimeOutError() throws Throwable {
		RestifRequestDto reqDto = null;
		RestifResponseDto resDto = null;

		setDebugOff();

		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.a.BeforeCreateToggledTimeOutError.create.req.xml");

		resDto = obj.createSlice(reqDto, equConf);
		assertNotNull(resDto);

		resDto = null;
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.n.001.delete.req.xml");
		resDto = obj.deleteSlice(reqDto, equConf);
		assertNotNull(resDto);
	}

	/**
	 * Test method for {@link org.o3project.mlo.server.impl.logic.SliceManager#createSlice(org.o3project.mlo.server.dto.RestifRequestDto)}.
	 */
	@Test
	public void testCreateSlice_a_AfterDeleteToggledDBAccessError() throws Throwable {
		RestifRequestDto reqDto = null;
		RestifResponseDto resDto = null;

		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.a.AfterDeleteToggledDBAccessError.create.req.xml");
		resDto = obj.createSlice(reqDto, equConf);
		assertNotNull(resDto);

		resDto = null;
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.n.001.delete.req.xml");
		try {
			resDto = obj.deleteSlice(reqDto, equConf);
			fail();
		} catch (MloException e) {
			assertTrue(e instanceof DbAccessException);
			assertEquals(null, resDto);
		}

		resDto = null;
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.n.001.delete.req.xml");
		try {
			resDto = obj.deleteSlice(reqDto, equConf);
			fail();
		} catch (MloException e) {
			assertTrue(e instanceof ApiCallException);
			assertEquals(null, resDto);
			assertEquals("AlreadyDeleted", e.getMessage());
		}
	}

	/**
	 * Test method for {@link org.o3project.mlo.server.impl.logic.SliceManager#createSlice(org.o3project.mlo.server.dto.RestifRequestDto)}.
	 */
	@Test
	public void testCreateSlice_a_DebugOff_AfterDeleteToggledDBAccessError() throws Throwable {
		RestifRequestDto reqDto = null;
		RestifResponseDto resDto = null;

		setDebugOff();

		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.a.AfterDeleteToggledDBAccessError.create.req.xml");
		resDto = obj.createSlice(reqDto, equConf);
		assertNotNull(resDto);

		resDto = null;
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.n.001.delete.req.xml");
		resDto = obj.deleteSlice(reqDto, equConf);
		assertNotNull(resDto);

		resDto = null;
		reqDto = DtoTestUtils.readReqFromXml(serdes, DATA_PATH, "dummy.n.001.delete.req.xml");
		try {
			resDto = obj.deleteSlice(reqDto, equConf);
			fail();
		} catch (MloException e) {
			assertTrue(e instanceof ApiCallException);
			assertEquals(null, resDto);
			assertEquals("AlreadyDeleted", e.getMessage());
		}
	}

	/**
	 * Sets debug.restif.enable to false.
	 */
	private void setDebugOff() {
		// debug.restif.enable = false
		// In this case, dummy exception must not occur.
		ConfigProviderImpl configProvider = ConfigProviderImplTest.createConfigProviderImpl((new File(DATA_PATH, "mlo-srv.debug-off.properties")).getAbsolutePath());
		DebugRestifChecker debugRestifChecker = new DebugRestifChecker();
		debugRestifChecker.setConfigProvider(configProvider);
		obj.setDebugRestifChecker(debugRestifChecker);
	}
}


text:
import random
import string

WORDLIST_FILENAME = "words.txt"

def loadWords():
    """
    Returns a list of valid words. Words are strings of lowercase letters.

    Depending on the size of the word list, this function may
    take a while to finish.
    """
    print "Loading word list from file..."
    # inFile: file
    inFile = open(WORDLIST_FILENAME, 'r', 0)
    # line: string
    line = inFile.readline()
    # wordlist: list of strings
    wordlist = string.split(line)
    print "  ", len(wordlist), "words loaded."
    return wordlist

def chooseWord(wordlist):
    """
    wordlist (list): list of words (strings)

    Returns a word from wordlist at random
    """
    return random.choice(wordlist)

# end of helper code
# -----------------------------------

# Load the list of words into the variable wordlist
# so that it can be accessed from anywhere in the program
wordlist = loadWords()

def isWordGuessed(secretWord, lettersGuessed):
    '''
    secretWord: string, the word the user is guessing
    lettersGuessed: list, what letters have been guessed so far
    returns: boolean, True if all the letters of secretWord are in lettersGuessed;
      False otherwise
    '''
    # FILL IN YOUR CODE HERE...
    return all(c in lettersGuessed for c in secretWord)

def getGuessedWord(secretWord, lettersGuessed):
    '''
    secretWord: string, the word the user is guessing
    lettersGuessed: list, what letters have been guessed so far
    returns: string, comprised of letters and underscores that represents
      what letters in secretWord have been guessed so far.
    '''
    # FILL IN YOUR CODE HERE...
    return ''.join(c if c in lettersGuessed else '_ ' for c in secretWord)

def getAvailableLetters(lettersGuessed):
    '''
    lettersGuessed: list, what letters have been guessed so far
    returns: string, comprised of letters that represents what letters have not
      yet been guessed.
    '''
    # FILL IN YOUR CODE HERE...
    s = 'abcdefghijklmnopqrstuvwxyz'
    return ''.join(c if c not in lettersGuessed else '' for c in s)

def finalmsg(result):
    print('------------')
    msgs = {'win': 'Congratulations, you won!',
            'lose': 'Sorry, you ran out of guesses. The word was else.'}
    print(msgs[result])

def hangman(secretWord):
    '''
    secretWord: string, the secret word to guess.

    Starts up an interactive game of Hangman.

    * At the start of the game, let the user know how many
      letters the secretWord contains.

    * Ask the user to supply one guess (i.e. letter) per round.

    * The user should receive feedback immediately after each guess
      about whether their guess appears in the computers word.

    * After each round, you should also display to the user the
      partially guessed word so far, as well as letters that the
      user has not yet guessed.

    Follows the other limitations detailed in the problem write-up.
    '''
    # FILL IN YOUR CODE HERE...
    TIMES = 8
    lettersGuessed = []
    avls = 'abcdefghijklmnopqrstuvwxyz'
    print('Welcome to the game, Hangman!')
    print('I am thinking of a word that is %d letters long.' % len(secretWord))
    while TIMES > 0:
        print('-------------')
        print('You have %d guesses left.' % TIMES)
        print('Available letters: %s' % getAvailableLetters(lettersGuessed))
        ltr = raw_input('Please guess a letter: ').lower()
        if ltr in lettersGuessed:
            print("Oops! You've already guessed that letter: %s" %
                    getGuessedWord(secretWord, lettersGuessed))
        elif ltr in secretWord:
            lettersGuessed.append(ltr)
            print('Good guess: %s' % getGuessedWord(secretWord,
                lettersGuessed))
            if isWordGuessed(secretWord, lettersGuessed):
                finalmsg('win')
                break
        else:
            lettersGuessed.append(ltr)
            print('Oops! That letter is not in my word: %s' %
                    getGuessedWord(secretWord, lettersGuessed))
            TIMES -= 1
    else:
        if isWordGuessed(secretWord, lettersGuessed):
            finalmsg('win')
        else:
            finalmsg('lose')

# When you've completed your hangman function, uncomment these two lines
# and run this file to test! (hint: you might want to pick your own
# secretWord while you're testing)

secretWord = chooseWord(wordlist).lower()
#secretWord = 'tortoise'
hangman(secretWord)

redpajama_set_name: RedPajamaGithub


text:
<!DOCTYPE html>

    <title>FuncyTown Example 9</title>
    <link rel="stylesheet" type="text/css" href="example_js.css">

example9_inheritance - funcyTags can inherit options from other funcy tags

      show FuncyTag html string output

Raw HTML output:

      show Javascript source code

Javascript Source Code:

    To Notice: New FuncyTags can be built by inheriting from previously defined FuncyTags.
    As a simple example, if we have already created a <span> tag like this:

span=funcyTag('span',{_nobrout:true,_nobrin:true});

we can then create a <big> tag that inherits everything about span but also sets the font size to be 150%:

big = funcyTag( span, {cssFontSize_pct:150} );

and a <bigred> tag could inherit from that to be a span that's both 150% bigger and colored red:

bigred = funcyTag( big, {cssColor:'red'} );

    next: example10_esc
    top: all js examples


text:
import os
import setuptools

def read_requires(base):
    path = os.path.join('tools', base)
    requires = []
    if not os.path.isfile(path):
        return requires
    with open(path, 'rb') as h:
        for line in h.read.splitlines():
            line = line.strip()
            if len(line) == 0 or line.startswith("#"):
                continue
            requires.append(line)
    return requires

setuptools.setup(
    name='taskflow',
    version='0.0.1',
    author='OpenStack',
    license='Apache Software License',
    description='Taskflow structured state management library.',
    long_description='The taskflow library provides core functionality that '
                     'can be used to build [resumable, reliable, '
                     'easily understandable, ...] highly available '
                     'systems which process workflows in a structured manner.',
    author_email='openstack-dev@lists.openstack.org',
    url='http://www.openstack.org/',
    tests_require=read_requires('test-requires'),
    install_requires=read_requires('pip-requires'),
    classifiers=[
        'Development Status :: 4 - Beta',
        'License :: OSI Approved :: Apache Software License',
        'Operating System :: POSIX :: Linux',
        'Programming Language :: Python :: 2.6', ],
)


text:
/*    */ package com.hundsun.network.gates.taiping.biz.common;
/*    */
/*    */ import javax.servlet.ServletContextEvent;
/*    */ import javax.servlet.ServletContextListener;
/*    */ import org.springframework.context.ApplicationContext;
/*    */ import org.springframework.web.context.WebApplicationContext;
/*    */ import org.springframework.web.context.support.WebApplicationContextUtils;
/*    */
/*    */ public class SpringContextInit
/*    */   implements ServletContextListener
/*    */ {
/*    */   private static WebApplicationContext springContext;
/*    */
/*    */   public void contextInitialized(ServletContextEvent event)
/*    */   {
/* 23 */     springContext = WebApplicationContextUtils.getWebApplicationContext(event.getServletContext());
/*    */   }
/*    */
/*    */   public void contextDestroyed(ServletContextEvent event)
/*    */   {
/*    */   }
/*    */
/*    */   public static ApplicationContext getApplicationContext() {
/* 31 */     return springContext;
/*    */   }
/*    */ }

/* Location:           E:\__安装归档\linquan-20161112\deploy14\fengshan\webroot\WEB-INF\classes\
 * Qualified Name:     com.hundsun.network.gates.taiping.biz.common.SpringContextInit
 * JD-Core Version:    0.6.0
 */


text:
<?php

namespace common\models;

use Yii;

class AddParamsBase extends \common\models\db\AddParamsDB {

    /**
     * @inheritdoc
     */
    public function attributeLabels() {
        return [
            'id' => Yii::t('backend', 'ID'),
            'module_id' => Yii::t('backend', 'Module'),
            'luong_nuoc_da_lam_nong' => Yii::t('backend', 'The water is heated'),
            'luong_dien_tieu_thu' => Yii::t('backend', 'Power Consumption'),
            'so_tien_tiet_kiem' => Yii::t('backend', 'Money of Saveings'),
            'luong_khi_thai_co2_giam' => Yii::t('backend', 'CO2 emissions decrease'),
        ];
    }

}


text:
title: "Docstore"
date: 2019-06-08T15:11:57-04:00
lastmod: 2019-07-29T12:00:00-07:00
showInSidenav: true
toc: true
---

The [`docstore` package][] provides an abstraction layer over common
[document stores](https://en.wikipedia.org/wiki/Document-oriented_database) like
Google Cloud Firestore, Amazon DynamoDB and MongoDB. This guide shows how to
work with document stores in the Go CDK.

<!--more-->

A document store is a service that stores data in semi-structured JSON-like
documents grouped into collections. Like other NoSQL databases, document stores
are schemaless.

The [`docstore` package][] supports operations to add, retrieve, modify and
delete documents.

Subpackages contain driver implementations of docstore for various services,
including Cloud and on-prem solutions. You can develop your application
locally using [`memdocstore`][], then deploy it to multiple Cloud providers with
minimal initialization reconfiguration.

[`docstore` package]: https://godoc.org/gocloud.dev/docstore
[`memdocstore`]: https://godoc.org/gocloud.dev/docstore/memdocstore

## Opening a Collection {#opening}

The first step in interacting with a document store is to instantiate
a portable [`*docstore.Collection`][] for your service.

While every docstore service has the concept of a primary key that uniquely
distinguishes a document in a collection, each one specifies that key in its own
way. To be portable, Docstore requires that the key be part of the document's
contents. When you open a collection using one of the functions described here,
you specify how to find the provider's primary key in the document.

The easiest way to open a collection is using [`docstore.OpenCollection`][] and
a service-specific URL pointing to it, making sure you ["blank import"][]
the driver package to link it in.

```go
import (
    "gocloud.dev/docstore"
    _ "gocloud.dev/docstore/<driver>"
)
...
coll, err := docstore.OpenCollection(context.Background(), "<driver-url>")
if err != nil {
    return fmt.Errorf("could not open collection: %v", err)
}
defer coll.Close()
// coll is a *docstore.Collection; see usage below
...
```

See [Concepts: URLs][] for general background and the [guide below][] for
URL usage for each supported service.

Alternatively, if you need
fine-grained control over the connection settings, you can call the constructor
function in the driver package directly (like `mongodocstore.OpenCollection`).

```go
import "gocloud.dev/docstore/<driver>"
...
coll, err := <driver>.OpenCollection(...)
...
```

You may find the [`wire` package][] useful for managing your initialization code
when switching between different backing services.

See the [guide below][] for constructor usage for each supported service

[`*docstore.Collection`]: https://godoc.org/gocloud.dev/docstore#Collection
[`docstore.OpenCollection`]:
https://godoc.org/gocloud.dev/docstore#OpenCollection
["blank import"]: https://golang.org/doc/effective_go.html#blank_import
[Concepts: URLs]: {{< ref "/concepts/urls.md" >}}
[guide below]: {{< ref "#services" >}}
[`wire` package]: http://github.com/google/wire

## Using a Collection {#using}

### Representing Documents {#rep-doc}

We'll use a collection with documents represented by this Go struct:

```go
type Player struct {
    Name             string
    Score            int
    DocstoreRevision interface{}
}
```

We recommend using structs for documents because they impose some structure on
your data, but Docstore also accepts `map[string]interface{}` values. See
[the `docstore` package documentation](https://godoc.org/gocloud.dev/docstore#hdr-Documents)
for more information.

The `DocstoreRevision` field holds information about the latest revision of the
document. We discuss it [below]({{< ref "#rev" >}}).

### Actions {#actions}

Once you have [opened a collection]( {{< ref "#opening" >}}), you can call
action methods on it to read, modify and write documents. You can execute a
single action, or run multiple actions together in an [_action list_]({{ ref
"act-list" }}).

Docstore supports six kinds of actions on documents:

-   `Get` retrieves a document.
-   `Create` creates a new document.
-   `Replace` replaces an existing document.
-   `Put` puts a document whether or not it already exists.
-   `Update` applies a set of modifications to a document.
-   `Delete` deletes a document.

You can create a single document with the `Collection.Create` method, we will
use `coll` as the variable holding the collection throughout the guide:

```go
err := coll.Create(ctx, &Player{Name: "Pat", Score: 10})
if err != nil {
    return err
}
```

#### Action Lists {#act-list}

When you use an action list to perform multiple actions at once, drivers can
optimize action lists by using bulk RPCs, running the actions concurrently,
or employing a provider's special features to improve efficiency and reduce
cost. Here we create several documents using an action list.

{{< goexample "gocloud.dev/docstore.ExampleCollection_Actions_bulkWrite" >}}

`ActionList` has a fluent API, so you can build and execute a sequence of
actions in one line of code. Here we `Put` a document and immediately `Get` its
new contents.

{{< goexample "gocloud.dev/docstore.ExampleCollection_Actions_getAfterWrite" >}}

If the underlying provider is eventually consistent, the result of the `Get`
might not reflect the `Put`. Docstore only guarantees that it will perform the
`Get` after the `Put` completes.

See the documentation for [`docstore.ActionList`][] for the semantics of action
list execution.

[`docstore.ActionList`]: https://godoc.org/gocloud.dev/docstore#ActionList

#### Updates {#act-update}

Use `Update` to modify individual fields of a document. The `Update` action
takes a set of modifications to document fields, and applies them all
atomically. You can change the value of a field, increment it, or delete it.

{{< goexample "gocloud.dev/docstore.ExampleCollection_Update" >}}

### Queries {#queries}

Docstore's `Get` action lets you retrieve a single document by its primary key.
Queries let you retrieve all documents that match some conditions. You can also
use queries to delete or update all documents that match the conditions.

#### Getting Documents {#qr-get}

Like [actions]({{< ref "#actions" >}}), queries are built up in a fluent
style. Just as a `Get` action returns one document, the `Query.Get` method
returns several documents, in the form of an iterator.

```go
iter := coll.Query().Where("Score", ">", 20).Get(ctx)
defer iter.Stop() // Always call Stop on an iterator.
```

Repeatedly calling `Next` on the iterator will return all the matching
documents. Like the `Get` action, `Next` will populate an empty document that
you pass to it:

```go
doc := &Player{}
err := iter.Next(ctx, doc)
```

The iteration is over when `Next` returns `io.EOF`.

{{< goexample "gocloud.dev/docstore.ExampleQuery_Get" >}}

You can pass a list of fields to `Get` to reduce the amount of data transmitted.

Queries support the following methods:

-   `Where` describes a condition on a document. You can ask whether a field is
    equal to, greater than, or less than a value. The "not equals" comparison
    isn't supported, because it isn't portable across providers.
-   `OrderBy` specifies the order of the resulting documents, by field and
    direction. For portability, you can specify at most one `OrderBy`, and its
    field must also be mentioned in a `Where` clause.
-   `Limit` limits the number of documents in the result.

If a query returns an error, the message may help you fix the problem. Some
features, like full table scans, have to be enabled via constructor options,
because they can be expensive. Other queries may require that you manually
create an index on the collection.

### Revisions {#rev}

Docstore maintains a revision for every document. Whenever the document is
changed, the revision is too. By default, Docstore stores the revision in a
field named `DocstoreRevision`, but you can change the field name via an option
to a `Collection` constructor.

You can use revisions to perform _optimistic locking_, a technique for updating
a document atomically:

1.  `Get` a document. This reads the current revision.
2.  Modify the document contents on the client (but do not change the revision).
3.  `Replace` the document. If the document was changed since it was retrieved
    in step 1, the revision will be different, and Docstore will return an error
    instead of overwriting the document.
4.  If the `Replace` failed, start again from step 1.

{{< goexample "gocloud.dev/docstore.Example_optimisticLocking" >}}

See
[the Revisions section of the package documentation](https://godoc.org/gocloud.dev/docstore#hdr-Revisions)
for more on revisions.

## Other Usage Samples

* [CLI Sample](https://github.com/google/go-cloud/tree/master/samples/gocdk-docstore)
* [Order Processor sample](https://gocloud.dev/tutorials/order/)
* [docstore package examples](https://godoc.org/gocloud.dev/docstore#pkg-examples)

## Supported Docstore Services {#services}

### Google Cloud Firestore {#firestore}

The [`gcpfirestore`](https://godoc.org/gocloud.dev/docstore/gcpfirestore)
package supports
[Google Cloud Firestore](https://cloud.google.com/firestore). Firestore
documents are uniquely named by paths that are not part of the document content.
In Docstore, these unique names are represented as part of the document. You
must supply a way to extract a document's name from its contents. This can be
done by specifying a document field that holds the name, or by providing a
function to extract the name from a document.

Firestore URLs provide the project and collection, as well as the field that
holds the document name.

`docstore.OpenCollection` will use Application Default Credentials; if you have
authenticated via [`gcloud auth application-default login`][], it will use those credentials. See
[Application Default Credentials][GCP creds] to learn about authentication
alternatives, including using environment variables.

[GCP creds]: https://cloud.google.com/docs/authentication/production
[`gcloud auth application-default login`]: https://cloud.google.com/sdk/gcloud/reference/auth/application-default/login

{{< goexample
"gocloud.dev/docstore/gcpfirestore.Example_openCollectionFromURL" >}}

Full details about acceptable URLs can be found under the API reference for
[`gcpfirestore.URLOpener`][].

[`gcpfirestore.URLOpener`]:  https://godoc.org/gocloud.dev/docstore/gcpfirestore#URLOpener

#### Firestore Constructors {#firestore-ctor}

The [`gcpfirestore.OpenCollection`][] constructor opens a Cloud Firestore
collection as a Docstore collection. You must first connect a Firestore client
using [`gcpfirestore.Dial`][] or the
[`cloud.google.com/go/firestore/apiv1`](https://godoc.org/cloud.google.com/go/firestore/apiv1)
package. In addition to a client, `OpenCollection` requires a Google Cloud
project ID, the path to the Firestore collection, and the name of the field that
holds the document name.

{{< goexample "gocloud.dev/docstore/gcpfirestore.ExampleOpenCollection" >}}

Instead of mapping the document name to a field, you can supply a function to
construct the name from the document contents with
[`gcpfirestore.OpenCollectionWithNameFunc`][]. This can be useful for documents
whose name is the combination of two or more fields.

{{< goexample
"gocloud.dev/docstore/gcpfirestore.ExampleOpenCollectionWithNameFunc" >}}

[`gcpfirestore.Dial`]: https://godoc.org/gocloud.dev/docstore/gcpfirestore#Dial
[`gcpfirestore.OpenCollection`]: https://godoc.org/gocloud.dev/docstore/gcpfirestore#OpenCollection
[`gcpfirestore.OpenCollectionWithNameFunc`]: https://godoc.org/gocloud.dev/docstore/gcpfirestore#OpenCollectionWithNameFunc

### Amazon DynamoDB {#dynamodb}

The [`awsdynamodb`](https://godoc.org/gocloud.dev/docstore/awsdynamodb) package
supports [Amazon DynamoDB](https://aws.amazon.com/dynamodb). A Docstore
collection corresponds to a DynamoDB table.

DynamoDB URLs provide the table, partition key field and optionally the sort key
field for the collection.

`docstore.OpenCollection` will create a default AWS Session with the
`SharedConfigEnable` option enabled; if you have authenticated with the AWS CLI,
it will use those credentials. See [AWS Session][] to learn about authentication
alternatives, including using environment variables.

[AWS Session]: https://docs.aws.amazon.com/sdk-for-go/api/aws/session/

{{< goexample
"gocloud.dev/docstore/awsdynamodb.Example_openCollectionFromURL" >}}

Full details about acceptable URLs can be found under the API reference for
[`awsdynamodb.URLOpener`][].

#### DynamoDB Constructor {#dynamodb-ctor}

The [`awsdynamodb.OpenCollection`][] constructor opens a DynamoDB table as a
Docstore collection. You must first create an [AWS session][] with the same
region as your collection:

{{< goexample "gocloud.dev/docstore/awsdynamodb.ExampleOpenCollection" >}}

[AWS session]: https://docs.aws.amazon.com/sdk-for-go/api/aws/session/
[`awsdynamodb.OpenCollection`]: https://godoc.org/gocloud.dev/docstore/awsdynamodb#OpenCollection
[`awsdynamodb.URLOpener`]: https://godoc.org/gocloud.dev/docstore/awsdynamodb#URLOpener

### Azure Cosmos DB {#cosmosdb}

[Azure Cosmos DB][] is compatible with the MongoDB API. You can use the
[`mongodocstore`][] package to connect to Cosmos DB. You must
[create an Azure Cosmos account][] and get the MongoDB [connection string][].

When you use MongoDB URLs to connect to Cosmos DB, specify the Mongo server
URL by setting the `MONGO_SERVER_URL` environment variable to the connection
string. See the [MongoDB section][] for more details and examples on how to
use the package.

[Azure Cosmos DB]: https://docs.microsoft.com/en-us/azure/cosmos-db/
[create an Azure Cosmos account]: https://docs.microsoft.com/en-us/azure/cosmos-db/create-mongodb-dotnet
[connection string]: https://docs.microsoft.com/en-us/azure/cosmos-db/connect-mongodb-account#QuickstartConnection
[MongoDB section]: {{< ref "#mongo" >}}

#### Cosmos DB Constructors {#cosmosdb-ctor}

The [`mongodocstore.OpenCollection`][] constructor can open a Cosmos DB
collection. You must first obtain a standard MongoDB Go client with your
Cosmos connections string. See the [MongoDB constructor section][] for more
details and examples.

[MongoDB constructor section]: {{< ref "#mongo-ctor" >}}

### MongoDB {#mongo}

The [`mongodocstore`][] package supports the popular
[MongoDB](https://mongodb.org) document store. MongoDB documents are uniquely
identified by a field called `_id`. In Docstore, you can choose a different
name for this field, or provide a function to extract the document ID from a
document.

MongoDB URLs provide the database and collection, and optionally the field that
holds the document ID. Specify the Mongo server URL by setting the
`MONGO_SERVER_URL` environment variable.

{{< goexample
"gocloud.dev/docstore/mongodocstore.Example_openCollectionFromURL" >}}

Full details about acceptable URLs can be found under the API reference for
[`mongodocstore.URLOpener`][].

[`mongodocstore.URLOpener`]:  https://godoc.org/gocloud.dev/docstore/mongodocstore#URLOpener

#### MongoDB Constructors {#mongo-ctor}

The [`mongodocstore.OpenCollection`][] constructor opens a MongoDB collection.
You must first obtain a standard MongoDB Go client using
[`mongodocstore.Dial`][] or the package
[`go.mongodb.org/mongo-driver/mongo`](https://godoc.org/go.mongodb.org/mongo-driver/mongo).
Obtain a `*mongo.Collection` from the client with
`client.Database(dbName).Collection(collName)`. Then pass the result to
`mongodocstore.OpenCollection` along with the name of the ID field, or `""` to
use `_id`.

{{< goexample "gocloud.dev/docstore/mongodocstore.ExampleOpenCollection" >}}

Instead of mapping the document ID to a field, you can supply a function to
construct the ID from the document contents with
[`mongodocstore.OpenCollectionWithIDFunc`][]. This can be useful for documents
whose name is the combination of two or more fields.

{{< goexample
"gocloud.dev/docstore/mongodocstore.ExampleOpenCollectionWithIDFunc" >}}

[`mongodocstore`]: https://godoc.org/gocloud.dev/docstore/mongodocstore
[`mongodocstore.Dial`]: https://godoc.org/gocloud.dev/docstore/mongodocstore#Dial
[`mongodocstore.OpenCollection`]: https://godoc.org/gocloud.dev/docstore/mongodocstore#OpenCollection
[`mongodocstore.OpenCollectionWithIDFunc`]: https://godoc.org/gocloud.dev/docstore/mongodocstore#OpenCollectionWithIDFunc

### In-Memory Document Store {#mem}

The [`memdocstore`](https://godoc.org/gocloud.dev/docstore/memdocstore)
package implements an in-memory document store suitable for testing and
development.

URLs for the in-memory store have a `mem:` scheme. The URL host is used as the
the collection name, and the URL path is used as the name of the document field
to use as a primary key.

{{< goexample
"gocloud.dev/docstore/memdocstore.Example_openCollectionFromURL" >}}

Full details about acceptable URLs can be found under the API reference for
[`memdocstore.URLOpener`][].

[`memdocstore.URLOpener`]:  https://godoc.org/gocloud.dev/docstore/memdocstore#URLOpener

#### Mem Constructors {#mem-ctor}

The [`memdocstore.OpenCollection`][] constructor creates and opens a collection,
taking the name of the key field.

{{< goexample "gocloud.dev/docstore/memdocstore.ExampleOpenCollection" >}}

You can instead supply a function to construct the primary key from the document
contents with [`memdocstore.OpenCollectionWithKeyFunc`][]. This can be useful
for documents whose name is the combination of two or more fields.

{{< goexample
"gocloud.dev/docstore/memdocstore.ExampleOpenCollectionWithKeyFunc" >}}

[`memdocstore.OpenCollection`]: https://godoc.org/gocloud.dev/docstore/memdocstore#OpenCollection
[`memdocstore.OpenCollectionWithKeyFunc`]: https://godoc.org/gocloud.dev/docstore/memdocstore#OpenCollectionWithKeyFunc


text:
export const environment = {
  production: true,
  snackBarDuration: 500
};


text:
cask "dynobase" do
  version "1.4.0"

  if Hardware::CPU.intel?
    sha256 "9954440dc838fc4459e72ed5d607c3e2c9f388dba07ca9c94b8cad115fb7abfd"

    url "https://github.com/Dynobase/dynobase/releases/download/#{version}/Dynobase-#{version}.dmg",
        verified: "github.com/Dynobase/dynobase/"
  else
    sha256 "7cb4e2831d1581ca7ee4227c4fb594bfa32a268f51aa38261b83ed018b396f4a"

    url "https://github.com/Dynobase/dynobase/releases/download/#{version}/Dynobase-#{version}-arm64.dmg",
        verified: "github.com/Dynobase/dynobase/"
  end

  name "Dynobase"
  desc "GUI Client for DynamoDB"
  homepage "https://dynobase.dev/"

  livecheck do
    url :url
    strategy :github_latest
  end

  app "Dynobase.app"

  zap trash: [
    "~/Library/Application Support/dynobase",
    "~/Library/Saved Application State/com.rwilinski.dynobase.savedState",
  ]
end


text:
<?php
/**
 * @author Mike Rodarte
 * @version 1.01
 */

/**
 * mtsapps namespace
 */
namespace mtsapps;

/**
 * Class PdfMerge
 *
 * @package mtsapps
 */
class PdfMerge
{
    /**
     * Debug flag: default to false
     *
     * @var bool
     */
    private $debug = false;

    /**
     * Author for PDF file
     *
     * @var string
     */
    private $author = 'Mike Rodarte';

    /**
     * Creator for PDF file
     *
     * @var string
     */
    private $creator = 'Mike Rodarte - mtsapps';

    /**
     * Directory name (for input and output)
     *
     * @var string
     */
    private $directory = __DIR__;

    /**
     * File names to merge into a single PDF file
     *
     * @var array
     */
    private $files = array();

    /**
     * Keywords for the PDF file
     *
     * @var array
     */
    private $keywords = array();

    /**
     * @var Log
     */
    protected $Log = null;

    /**
     * Initial log level
     *
     * @var int
     */
    private $log_level = 0;

    /**
     * Page orientation (P|L)
     *
     * @var string
     */
    private $orientation = 'P';

    /**
     * Output file name (without directory)
     *
     * @var string
     */
    private $output_file = 'output.pdf';

    /**
     * Owner password for PDF file
     *
     * @var string
     */
    private $owner_password = '';

    /**
     * Paper size
     *
     * @var string
     * @see TCPDF_STATIC::getPageSizeFromFormat()
     */
    private $paper_size = 'Letter';

    /**
     * Subject of the PDF file
     *
     * @var string
     */
    private $subject = 'mtsapps PDF Merge';

    /**
     * Title of the PDF file
     *
     * @var string
     */
    private $title = 'mtsapps PDF Merge';

    /**
     * User password for PDF file
     *
     * @var string
     */
    private $user_password = '';

    /**
     * PdfMerge constructor.
     *
     * @param array $params
     */
    public function __construct($params = array())
    {
        $this->Log = new Log([
            'file' => 'pdf-merge_' . date('Y-m-d') . '.log',
        ]);
        $this->logLevel(Log::LOG_LEVEL_WARNING);

        if (Helpers::is_array_ne($params)) {
            if (array_key_exists('log_level', $params)) {
                $this->logLevel($params['log_level']);
            }
            $this->Log->write('params', Log::LOG_LEVEL_USER, $params);

            // set properties based on parameters
            foreach ($params as $param => $value) {
                $method = Helpers::upper_camel($param);
                $this->$method($value);
            }
        }
    }

    /**
     * Merge PDF files together in the order they were entered to the $files array.
     *
     * @return string|bool
     * @see http://stackoverflow.com/questions/19855712/merge-multiple-pdf-files-into-one-in-php#answer-19856524
     * @uses FPDI_Protection::setSourceFile()
     * @uses FPDI_Protection::importPage()
     * @uses FPDI_Protection::addPage()
     * @uses FPDI_Protection::useTemplate()
     * @uses FPDI_Protection::SetAuthor()
     * @uses FPDI_Protection::SetCreator()
     * @uses FPDI_Protection::SetTitle()
     * @uses FPDI_Protection::SetSubject()
     * @uses FPDI_Protection::SetKeywords()
     * @uses FPDI_Protection::Output()
     */
    public function merge()
    {
        $this->Log->write(__METHOD__, Log::LOG_LEVEL_SYSTEM_INFORMATION);

        // input validation
        if (!Helpers::is_array_ne($this->files)) {
            $this->Log->write('Files is not an array. Enter at least 1 file before attempting to combine.', Log::LOG_LEVEL_WARNING);

            return false;
        }

        try {
            $pdf = new \FPDI_Protection();
            foreach ($this->files as $file) {
                $page_count = $pdf->setSourceFile($this->directory . $file);
                for ($j = 0; $j < $page_count; $j++) {
                    $template_index = $pdf->importPage(($j + 1), '/MediaBox');
                    $pdf->addPage($this->orientation, $this->paper_size);
                    $pdf->useTemplate($template_index, 0, 0, 0, 0, true);
                }

                // CAUTION: Delete the PDF input file if not debugging.
                if (!$this->debug) {
                    unlink($file);
                }
            }

            $pdf->SetAuthor($this->author);
            $pdf->SetCreator($this->creator);
            $pdf->SetTitle($this->title);
            $pdf->SetSubject($this->subject);
            $pdf->SetKeywords(implode(', ', $this->keywords));

            if (Helpers::is_string_ne($this->user_password)) {
                $pdf->SetProtection(array('print', 'copy'), $this->user_password, $this->owner_password);
            }

            $output_path = $this->directory . $this->output_file;
            $this->Log->write('output file path', Log::LOG_LEVEL_USER, $output_path);
            $output = $pdf->Output('F', $output_path);

            if ($output === '') {
                // file was created
                return $output_path;
            } else {
                $this->Log->write('Error writing file to output', Log::LOG_LEVEL_WARNING, $output);
                return $output;
            }
        } catch (\Exception $ex) {
            $this->Log->exception($ex);

            return false;
        }
    }

    // BEGIN setters and getters
    /**
     * Add a file to the array.
     *
     * @param string $file
     * @return bool
     */
    public function addFile($file = '')
    {
        if (!Helpers::is_string_ne($file) || !is_file($file)) {
            return false;
        }

        $this->files[] = $file;

        return true;
    }

    /**
     * Add a keyword to the array.
     *
     * @param string $keyword
     * @return bool
     */
    public function addKeyword($keyword = '')
    {
        if (!Helpers::is_string_ne($keyword)) {
            return false;
        }

        $this->keywords[] = $keyword;

        return true;
    }

    /**
     * Set and/or get the author name.
     *
     * [@param] string|array|mixed $author
     * @return string
     */
    public function author()
    {
        $args = func_get_args();
        if (Helpers::is_array_ne($args)) {
            if (Helpers::is_string_ne($args[0])) {
                $this->author = $args[0];
            } elseif (Helpers::is_array_ne($args[0])) {
                $this->author = implode(', ', $args[0]);
            } else {
                $this->author = Helpers::get_string($args[0]);
            }
        }

        return $this->author;
    }

    /**
     * Set and/or get the creator.
     *
     * [@param] string|array|mixed $creator
     * @return string
     */
    public function creator()
    {
        $args = func_get_args();
        if (Helpers::is_array_ne($args)) {
            if (Helpers::is_string_ne($args[0])) {
                $this->creator = $args[0];
            } elseif (Helpers::is_array_ne($args[0])) {
                $this->creator = implode(', ', $args[0]);
            } else {
                $this->creator = Helpers::get_string($args[0]);
            }
        }

        return $this->creator;
    }

    /**
     * Set and/or get the debug flag.
     *
     * @return bool
     */
    public function debug()
    {
        $args = func_get_args();
        if (Helpers::is_array_ne($args)) {
            if (is_bool($args[0])) {
                $this->debug = $args[0];
            } else {
                $this->debug = !!$args[0];
            }
        }

        return $this->debug;
    }

    /**
     * Set and/or get the directory path.
     *
     * [@param] string $directory
     * @return string
     */
    public function directory()
    {
        $args = func_get_args();
        if (Helpers::is_array_ne($args)) {
            if (Helpers::is_string_ne($args[0]) && is_dir($args[0])) {
                $this->directory = $args[0];
            }
        }

        return $this->directory;
    }

    /**
     * Set and/or get the files array.
     *
     * [@param] array|string $files
     * @return array
     */
    public function files()
    {
        $args = func_get_args();
        if (Helpers::is_array_ne($args)) {
            if (Helpers::is_array_ne($args[0])) {
                $this->files = $args[0];
            } elseif (Helpers::is_string_ne($args[0])) {
                $this->addFile($args[0]);
            }
        }

        return $this->files;
    }

    /**
     * Set and/or get the keywords array.
     *
     * [@param] array|string $keywords
     * @return array
     */
    public function keywords()
    {
        $args = func_get_args();
        if (Helpers::is_array_ne($args)) {
            if (Helpers::is_array_ne($args[0])) {
                $this->keywords = $args[0];
            } elseif (Helpers::is_string_ne($args[0])) {
                $this->addKeyword($args[0]);
            }
        }

        return $this->keywords;
    }

    /**
     * Set and/or get the log level.
     *
     * @return int
     * @uses Log::validateLevel()
     */
    public function logLevel()
    {
        $args = func_get_args();
        if (Helpers::is_array_ne($args)) {
            if (Helpers::is_valid_int($args[0]) && (is_object($this->Log) && $this->Log->validateLevel($args[0]))) {
                $this->log_level = $args[0];
                $this->Log->logLevel($this->log_level);
            }
        }

        return $this->log_level;
    }

    /**
     * Set and/or get the orientation.
     *
     * [@param] string P|L
     * @return string
     */
    public function orientation()
    {
        $args = func_get_args();
        if (Helpers::is_array_ne($args)) {
            if (Helpers::is_string_ne($args[0]) && in_array(strtoupper($args[0]), array('P', 'L'))) {
                $this->orientation = strtoupper($args[0]);
            } else {
                $this->Log->write('Invalid orientation {' . $args[0] . '} provided. Need to specify P or L.', Log::LOG_LEVEL_WARNING);
            }
        }

        return $this->orientation;
    }

    /**
     * Set and/or get the output file name. This should be the base name of the file, though full path is supported.
     *
     * [@param] string $output_file
     * @return string
     */
    public function outputFile()
    {
        $args = func_get_args();
        if (Helpers::is_array_ne($args)) {
            if (Helpers::is_string_ne($args[0])) {
                $base_name = pathinfo($args[0], PATHINFO_BASENAME);
                if ($base_name != $args[0]) {
                    $directory = pathinfo($args[0], PATHINFO_DIRNAME);
                    if (Helpers::is_string_ne($directory)) {
                        if (is_dir($directory)) {
                            $this->Log->write('Need to set directory from ' . __FUNCTION__, Log::LOG_LEVEL_SYSTEM_INFORMATION);
                            $this->directory($directory);
                        }
                    }
                }
                $this->output_file = $base_name;
            }
        }

        return $this->output_file;
    }

    /**
     * Set and/or get owner password for PDF file.
     *
     * @return string
     */
    public function ownerPassword()
    {
        $args = func_get_args();
        if (Helpers::is_array_ne($args)) {
            if (Helpers::is_string_ne($args[0])) {
                $this->owner_password = $args[0];
            } else {
                $this->Log->write('invalid type for owner password', Log::LOG_LEVEL_WARNING);
            }
        }

        return $this->owner_password;
    }

    /**
     * Set and/or get the paper size.
     *
     * @return string
     * @see TCPDF_STATIC::getPageSizeFromFormat()
     */
    public function paperSize()
    {
        $args = func_get_args();
        if (Helpers::is_array_ne($args)) {
            if (Helpers::is_string_ne($args[0])) {
                $this->paper_size = $args[0];
            } else {
                $this->Log->write('Invalid paper size provided.', Log::LOG_LEVEL_WARNING);
            }
        }

        return $this->paper_size;
    }

    /**
     * Set and/or get the subject.
     *
     * [@param] string $subject
     * @return string
     */
    public function subject()
    {
        $args = func_get_args();
        if (Helpers::is_array_ne($args)) {
            if (Helpers::is_string_ne($args[0])) {
                $this->subject = $args[0];
            }
        }

        return $this->subject;
    }

    /**
     * Set and/or get the title.
     *
     * [@param] string $title
     * @return string
     */
    public function title()
    {
        $args = func_get_args();
        if (Helpers::is_array_ne($args)) {
            if (Helpers::is_string_ne($args[0])) {
                $this->title = $args[0];
            }
        }

        return $this->title;
    }

    /**
     * Set and/or get user password for PDF file. If this is set, the PDF file will be encrypted.
     *
     * @return string
     */
    public function userPassword()
    {
        $args = func_get_args();
        if (Helpers::is_array_ne($args)) {
            if (Helpers::is_string_ne($args[0])) {
                $this->user_password = $args[0];
            } else {
                $this->Log->write('invalid type for user password', Log::LOG_LEVEL_WARNING);
            }
        }

        return $this->user_password;
    }

    /**
     * Magic method for getter that uses defined methods or the property to return properties.
     *
     * @param string $name
     * @return mixed|null
     */
    public function __get($name = '')
    {
        $this->Log->write(__METHOD__, Log::LOG_LEVEL_SYSTEM_INFORMATION);

        $property = Helpers::lower_underscore($name);
        if (property_exists($this, $property)) {
            $method = Helpers::upper_camel($name);
            if (method_exists($this, $method)) {
                return $this->$method();
            } else {
                return $this->$property;
            }
        } else {
            $this->Log->write('Error: property {' . $property . '} does not exist.', Log::LOG_LEVEL_WARNING);

            return null;
        }
    }

    /**
     * Magic method for setter that uses defined methods or matches type to set properties.
     *
     * @param string $name
     * @param mixed $value
     * @uses lower_underscore()
     * @uses upper_camel(0
     */
    public function __set($name = '', $value)
    {
        $this->Log->write(__METHOD__, Log::LOG_LEVEL_SYSTEM_INFORMATION, $value);

        $property = Helpers::lower_underscore($name);
        if (property_exists($this, $property)) {
            $method = Helpers::upper_camel($name);
            if (method_exists($this, $method)) {
                $this->$method($value);
            } else {
                $property_type = gettype($this->$property);
                $value_type = gettype($value);
                if ($property_type == $value_type) {
                    $this->$property = $value;
                } else {
                    $this->Log->write('Error: value type mismatch in __set(): {' . $property_type . '} != {' . $value_type . '}', Log::LOG_LEVEL_WARNING);
                }
            }
        } else {
            $this->Log->write('property {' . $property . '} does not exist.', Log::LOG_LEVEL_WARNING);
        }
    }

    // END setters and getters

    /**
     * Undefined method call handler
     *
     * @param string $name
     * @param array $arguments
     */
    public function __call($name = '', $arguments = array())
    {
        $this->Log->write(__METHOD__, Log::LOG_LEVEL_SYSTEM_INFORMATION, $arguments);

        if (!method_exists($this, $name)) {
            $this->Log->write($name . ' is not a callable method.', Log::LOG_LEVEL_WARNING);
        } else {
            call_user_func_array(array($this, $name), $arguments);
        }
    }
}


text:
package utils

import (
	"fmt"
	"os"
	"path/filepath"
	"regexp"
	"sort"
	"strings"
)

var (
	headerRegexp        = regexp.MustCompile(`\.(h|hpp|inc)$`)
	compileSourceRegexp = regexp.MustCompile(`\.(c|s|cpp|cc|S)$`)
)

// Does the input string look like it is a header file?
func IsHeader(s string) bool {
	return headerRegexp.MatchString(s)
}

// Does the input string look like it is a source file?
func IsNotHeader(s string) bool {
	return !headerRegexp.MatchString(s)
}

// IsCompilableSource checks if filename extension is a compiled one
func IsCompilableSource(s string) bool {
	return compileSourceRegexp.MatchString(s)
}

// IsNotCompilableSource checks if filename extension isn't a compiled one
func IsNotCompilableSource(s string) bool {
	return !compileSourceRegexp.MatchString(s)
}

// Prefixes a string to every item in a list
func PrefixAll(list []string, prefix string) []string {
	output := []string{}
	for _, s := range list {
		output = append(output, prefix+s)
	}
	return output
}

// Prefixes a directory to every file in a list
// The returned file paths are the shortest paths (../ removed)
func PrefixDirs(paths []string, dir string) []string {
	output := []string{}
	for _, p := range paths {
		output = append(output, filepath.Join(dir, p))
	}
	return output
}

func SortedKeys(m map[string]string) []string {
	keys := make([]string, len(m))

	i := 0
	for key := range m {
		keys[i] = key
		i++
	}

	sort.Strings(keys)

	return keys
}

func SortedKeysBoolMap(m map[string]bool) []string {
	keys := make([]string, len(m))

	i := 0
	for key := range m {
		keys[i] = key
		i++
	}

	sort.Strings(keys)

	return keys
}

func SortedKeysByteSlice(m map[string][]byte) []string {
	keys := make([]string, len(m))

	i := 0
	for key := range m {
		keys[i] = key
		i++
	}

	sort.Strings(keys)

	return keys
}

/* Identifies whether the array 'list' contains the string 'x'. */
func Contains(list []string, x string) bool {
	for _, y := range list {
		if y == x {
			return true
		}
	}
	return false
}

func ListsContain(x string, lists ...[]string) bool {
	for _, list := range lists {
		if Contains(list, x) {
			return true
		}
	}
	return false
}

func Filter(predicate func(string) bool, lists ...[]string) (ret []string) {
	for _, list := range lists {
		for _, s := range list {
			if predicate(s) {
				ret = append(ret, s)
			}
		}
	}
	return
}

// return s after removing elements found in t
func Difference(s []string, t []string) []string {
	var diff []string
	for _, element := range s {
		if !Contains(t, element) {
			diff = append(diff, element)
		}
	}
	return diff
}

func AppendIfUnique(destination []string, value string) []string {
	if !Contains(destination, value) {
		return append(destination, value)
	}

	return destination
}

func AppendUnique(destination []string, source []string) []string {
	if len(source) < 1 {
		return destination
	}

	output := make([]string, len(destination))
	copy(output, destination)

	for _, value := range source {
		output = AppendIfUnique(output, value)
	}

	return output
}

// Find returns the smallest index i at which x == a[i],
// or -1 if there is no such index.
func Find(a []string, x string) int {
	for i, n := range a {
		if x == n {
			return i
		}
	}
	return -1
}

func Remove(a []string, x string) []string {
	position := Find(a, x)
	if position != -1 {
		return append(a[:position], a[position+1:]...)
	}
	return a
}

// Return a reversed a string array.
// This ought to be able to be done generically for any array type by using interfaces,
// but we only need to handle strings for now
func Reversed(in []string) []string {
	size := len(in)
	last := size - 1
	out := make([]string, size)
	for i, s := range in {
		out[last-i] = s
	}
	return out
}

// `cmd` is the command that will be executed
// Return true if it contains a reference to the argument expansion `arg`
func ContainsArg(cmd string, k string) bool {
	// argument ref can be done as ${arg} or $arg
	if strings.Contains(cmd, "${"+k+"}") || strings.Contains(cmd, "$"+k) {
		return true
	}
	return false
}

// cmd is the command that will be executed
// args contains potential argument that may occur in ${}
// This function will remove unused arguments from the map
func StripUnusedArgs(args map[string]string, cmd string) {
	for k := range args {
		if !ContainsArg(cmd, k) {
			delete(args, k)
		}
	}
}

func Trim(args []string) []string {
	out := []string{}
	for _, element := range args {
		if trim := strings.TrimSpace(element); len(trim) > 0 {
			out = append(out, trim)
		}
	}
	return out
}

// Join multiple lists of strings. This replaces appending multiple arrays
// together before calling strings.Join().
func Join(lists ...[]string) string {
	var sb strings.Builder
	const sep = " "
	first := true

	for _, list := range lists {
		listJoined := strings.Join(list, sep)
		if len(listJoined) > 0 {
			if !first {
				sb.WriteString(sep)
			} else {
				first = false
			}
			sb.WriteString(listJoined)
		}
	}

	return sb.String()
}

// IsExecutable returns true if the given file exists and is executable
func IsExecutable(fname string) bool {
	if fi, err := os.Stat(fname); !os.IsNotExist(err) && (fi.Mode()&0111 != 0) {
		return true
	}
	return false
}

// NewStringSlice initialises a new slice from the input lists, which are concatenated.
// The in-built append function modifies the slice buffer of the existing slice.
// This means that using append has side-effect on the first list.
// The purpose of this function is to avoid those side-effects.
func NewStringSlice(lists ...[]string) []string {
	// Checkout utils test for example why this is different to append()
	sumSize := 0
	for _, list := range lists {
		sumSize += len(list)
	}
	allLists := make([]string, 0, sumSize)
	for _, list := range lists {
		allLists = append(allLists, list...)
	}
	return allLists
}

// Exit the program, printing a message to stderr.
// Deferred functions will not execute.
func Exit(exitCode int, err string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, err+"\n", a...)
	os.Exit(exitCode)
}

func Die(err string, a ...interface{}) {
	Exit(1, err, a...)
}

// FlattenPath produces a filename containing no slashes from a path.
func FlattenPath(s string) string {
	return strings.Replace(s, "/", "__", -1)
}

// Expand function is similar to os.Expand, with one difference: curly braces
// around variable names are compulsory - this only replaces recognized
// variable references. In particular, '$' followed by a character other than
// '{' will not be affected by expansion. E.g. "$a" will remain "$a" after
// expansion.
func Expand(s string, mapping func(string) string) (res string) {
	const (
		outsideRef = iota
		enteringRef
		insideRef
	)
	state := outsideRef
	variable := ""
	for _, c := range s {
		switch state {
		case outsideRef:
			if c == '$' {
				state = enteringRef
			} else {
				res += string(c)
			}
		case enteringRef:
			if c == '{' {
				state = insideRef
			} else {
				res += "$" + string(c)
				state = outsideRef
			}
		case insideRef:
			if c == '}' {
				res += mapping(variable)
				variable = ""
				state = outsideRef
			} else {
				variable += string(c)
			}
		}
	}
	if state == enteringRef {
		res += "$"
	} else if state == insideRef {
		res += "${" + variable
	}
	return
}

func SplitPath(path string) (components []string) {
	pathSep := string(os.PathSeparator)

	if path == "" {
		return []string{}
	} else if path == pathSep {
		return []string{pathSep}
	}

	// Ignore trailing slashes
	if path[len(path)-1:] == pathSep {
		path = path[:len(path)-1]
	}

	dir, file := filepath.Split(path)

	if dir == "" {
		return []string{file}
	} else if dir == pathSep {
		// Treat subdirs of the root directory as single components, e.g. /var -> ["/var"].
		return []string{path}
	}

	return append(SplitPath(dir), file)
}


text:
/**
 *@file lv_themes.h
 *
 */

#ifndef LV_THEMES_H
#define LV_THEMES_H

#ifdef __cplusplus
extern "C" {
#endif

/*********************
 *    INCLUDES
 *********************/
#include "../lv_conf_internal.h"
#include "../lv_core/lv_style.h"
#include "../lv_core/lv_obj.h"

/*********************
 *    DEFINES
 *********************/

/**********************
 *    TYPEDEFS
 **********************/

/**
 * A theme in LVGL consists of many styles bound together.
 *
 * There is a style for each object type, as well as a generic style for
 * backgrounds and panels.
 */
typedef enum {
    LV_THEME_NONE = 0,
    LV_THEME_SCR,
    LV_THEME_OBJ,
#if LV_USE_ARC
    LV_THEME_ARC,
#endif
#if LV_USE_BAR
    LV_THEME_BAR,
#endif
#if LV_USE_BTN
    LV_THEME_BTN,
#endif
#if LV_USE_BTNMATRIX
    LV_THEME_BTNMATRIX,
#endif
#if LV_USE_CALENDAR
    LV_THEME_CALENDAR,
#endif
#if LV_USE_CANVAS
    LV_THEME_CANVAS,
#endif
#if LV_USE_CHECKBOX
    LV_THEME_CHECKBOX,
#endif
#if LV_USE_CHART
    LV_THEME_CHART,
#endif
#if LV_USE_CONT
    LV_THEME_CONT,
#endif
#if LV_USE_CPICKER
    LV_THEME_CPICKER,
#endif
#if LV_USE_DROPDOWN
    LV_THEME_DROPDOWN,
#endif
#if LV_USE_GAUGE
    LV_THEME_GAUGE,
#endif
#if LV_USE_IMG
    LV_THEME_IMAGE,
#endif
#if LV_USE_IMGBTN
    LV_THEME_IMGBTN,
#endif
#if LV_USE_KEYBOARD
    LV_THEME_KEYBOARD,
#endif
#if LV_USE_LABEL
    LV_THEME_LABEL,
#endif
#if LV_USE_LED
    LV_THEME_LED,
#endif
#if LV_USE_LINE
    LV_THEME_LINE,
#endif
#if LV_USE_LIST
    LV_THEME_LIST,
    LV_THEME_LIST_BTN,
#endif
#if LV_USE_LINEMETER
    LV_THEME_LINEMETER,
#endif
#if LV_USE_MSGBOX
    LV_THEME_MSGBOX,
    LV_THEME_MSGBOX_BTNS,   /*The button matrix of the buttons are initialized separately*/
#endif
#if LV_USE_OBJMASK
    LV_THEME_OBJMASK,
#endif
#if LV_USE_PAGE
    LV_THEME_PAGE,
#endif
#if LV_USE_ROLLER
    LV_THEME_ROLLER,
#endif
#if LV_USE_SLIDER
    LV_THEME_SLIDER,
#endif
#if LV_USE_SPINBOX
    LV_THEME_SPINBOX,
    LV_THEME_SPINBOX_BTN,   /*Control button for the spinbox*/
#endif
#if LV_USE_SPINNER
    LV_THEME_SPINNER,
#endif
#if LV_USE_SWITCH
    LV_THEME_SWITCH,
#endif
#if LV_USE_TABLE
    LV_THEME_TABLE,
#endif
#if LV_USE_TABVIEW
    LV_THEME_TABVIEW,
    LV_THEME_TABVIEW_PAGE,  /*The tab pages are initialized separately*/
#endif
#if LV_USE_TEXTAREA
    LV_THEME_TEXTAREA,
#endif
#if LV_USE_TILEVIEW
    LV_THEME_TILEVIEW,
#endif
#if LV_USE_WIN
    LV_THEME_WIN,
    LV_THEME_WIN_BTN,   /*The buttons are initialized separately*/
#endif

    _LV_THEME_BUILTIN_LAST,
    LV_THEME_CUSTOM_START = _LV_THEME_BUILTIN_LAST,
    _LV_THEME_CUSTOM_LAST = 0xFFFF,

} lv_theme_style_t;

struct _lv_theme_t;

typedef void (*lv_theme_apply_cb_t)(struct _lv_theme_t *, lv_obj_t *, lv_theme_style_t);
typedef void (*lv_theme_apply_xcb_t)(lv_obj_t *, lv_theme_style_t); /*Deprecated: use `apply_cb` instead*/

typedef struct _lv_theme_t {
    lv_theme_apply_cb_t apply_cb;
    lv_theme_apply_xcb_t apply_xcb; /*Deprecated: use `apply_cb` instead*/
    struct _lv_theme_t * base;    /**< Apply the current theme's style on top of this theme.*/
    lv_color_t color_primary;
    lv_color_t color_secondary;
    const lv_font_t * font_small;
    const lv_font_t * font_normal;
    const lv_font_t * font_subtitle;
    const lv_font_t * font_title;
    uint32_t flags;
    void * user_data;
} lv_theme_t;

/**********************
 *  GLOBAL PROTOTYPES
 **********************/

/**
 * Set a theme for the system.
 * From now, all the created objects will use styles from this theme by default
 * @param th pointer to theme (return value of: 'lv_theme_init_xxx()')
 */
void lv_theme_set_act(lv_theme_t * th);

/**
 * Get the current system theme.
 * @return pointer to the current system theme. NULL if not set.
 */
lv_theme_t * lv_theme_get_act(void);

/**
 * Apply the active theme on an object
 * @param obj pointer to an object
 * @param name the name of the theme element to apply. E.g. `LV_THEME_BTN`
 */
void lv_theme_apply(lv_obj_t * obj, lv_theme_style_t name);

/**
 * Copy a theme to an other or initialize a theme
 * @param theme pointer to a theme to initialize
 * @param copy pointer to a theme to copy
 *             or `NULL` to initialize `theme` to empty
 */
void lv_theme_copy(lv_theme_t * theme, const lv_theme_t * copy);

/**
 * Set a base theme for a theme.
 * The styles from the base them will be added before the styles of the current theme.
 * Arbitrary long chain of themes can be created by setting base themes.
 * @param new_theme pointer to theme which base should be set
 * @param base pointer to the base theme
 */
void lv_theme_set_base(lv_theme_t * new_theme, lv_theme_t * base);

/**
 * Set an apply callback for a theme.
 * The apply callback is used to add styles to different objects
 * @param theme pointer to theme which callback should be set
 * @param apply_cb pointer to the callback
 */
void lv_theme_set_apply_cb(lv_theme_t * theme, lv_theme_apply_cb_t apply_cb);

/**
 * Get the small font of the theme
 * @return pointer to the font
 */
const lv_font_t * lv_theme_get_font_small(void);

/**
 * Get the normal font of the theme
 * @return pointer to the font
 */
const lv_font_t * lv_theme_get_font_normal(void);

/**
 * Get the subtitle font of the theme
 * @return pointer to the font
 */
const lv_font_t * lv_theme_get_font_subtitle(void);

/**
 * Get the title font of the theme
 * @return pointer to the font
 */
const lv_font_t * lv_theme_get_font_title(void);

/**
 * Get the primary color of the theme
 * @return the color
 */
lv_color_t lv_theme_get_color_primary(void);

/**
 * Get the secondary color of the theme
 * @return the color
 */
lv_color_t lv_theme_get_color_secondary(void);

/**
 * Get the flags of the theme
 * @return the flags
 */
uint32_t lv_theme_get_flags(void);

/**********************
 *    MACROS
 **********************/

/**********************
 *     POST INCLUDE
 *********************/
#include "lv_theme_empty.h"
#include "lv_theme_template.h"
#include "lv_theme_material.h"
#include "lv_theme_mono.h"

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif /*LV_THEMES_H*/


text:
package org.project.openbaton.nubomedia.paas.core.openshift.builders;

import org.project.openbaton.nubomedia.paas.model.openshift.*;

/**
 * Created by maa on 25/09/2015.
 */
public class DeploymentMessageBuilder {

  private String name;
  private Container[] containers;
  private int replicaNumber;
  private ImageChangeTrigger[] triggers;
  private String strategyType;

  public DeploymentMessageBuilder(
      String name,
      Container[] containers,
      int replicaNumber,
      ImageChangeTrigger[] triggers,
      String strategyType) {
    this.name = name;
    this.containers = containers;
    this.replicaNumber = replicaNumber;
    this.triggers = triggers;
    this.strategyType = strategyType;
  }

  public DeploymentConfig buildMessage() {

    Metadata metadata = new Metadata(name + "-dc", "", "");
    MetadataDeploy metadeploy = new MetadataDeploy(new MetadataDeploy.Labels(name));
    Selector selector = new Selector(name);
    DeploymentConfigSpec.Strategy strategy = new DeploymentConfigSpec.Strategy(strategyType);

    DeploymentConfigSpec spec =
        new DeploymentConfigSpec(
            new Template(metadeploy, new SpecDeploy(containers)),
            replicaNumber,
            selector,
            triggers,
            strategy);

    return new DeploymentConfig(metadata, spec);
  }
}


text:
package org.proust.core.service;

public interface BizTopicService {

}


text:
cd ~

mkdir repos
cd repos

git clone https://github.com/Anton04/InstallPlayground.git


text:
import ast

from wtforms.fields import Field

def slider_widget(field, ul_class='', **kwargs):
    """widget for rendering a SliderField"""
    # THE BELOW IS JUST AN EXAMPLE, NOTHING TO DO WITH SLIDER
    kwargs.setdefault('type', 'checkbox')
    field_id = kwargs.pop('id', field.id)
    html = [u'
' % html_params(id=field_id, class_=ul_class)]
    for value, label, checked in field.iter_choices():
        choice_id = u'%s-%s' % (field_id, value)
        options = dict(kwargs, name=field.name, value=value, id=choice_id)
        if checked:
            options['checked'] = 'checked'
        html.append(u'
<input %s /> ' % html_options(**options))
        html.append(u'%s
')
    html.append(u'
')
    return u''.join(html)

class SliderField(Field):
    widget = slider_widget

    def __init__(self, id, min, max, value):
        self.id = id
        self.min = min
        self.max = max
        self.value = value

    def _value(self):
        return self.data

    def process_formdata(self, input):
        self.data = ast.literal_eval(input[0])


text:
<?php

namespace WikiRenderer\Generator\Html;

class Document extends \WikiRenderer\Generator\AbstractDocumentGenerator
{
}


text:
package com.InfinityRaider.AgriCraft.renderers;

import com.InfinityRaider.AgriCraft.compatibility.LoadedMods;
import com.InfinityRaider.AgriCraft.compatibility.natura.NaturaHelper;
import com.InfinityRaider.AgriCraft.models.ModelCrop;
import com.InfinityRaider.AgriCraft.reference.Constants;
import com.InfinityRaider.AgriCraft.reference.Reference;
import com.InfinityRaider.AgriCraft.tileentity.TileEntityCrop;
import com.InfinityRaider.AgriCraft.utility.RenderHelper;
import com.InfinityRaider.AgriCraft.utility.SeedHelper;
import net.minecraft.block.BlockBush;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemSeeds;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;

public class RenderCrop extends TileEntitySpecialRenderer{
    private ResourceLocation textureCross;
    private ResourceLocation textureEmpty;
    private final ModelCrop model;

    public RenderCrop() {
        this.model = new ModelCrop();
        this.textureCross = new ResourceLocation(Reference.MOD_ID.toLowerCase()+":textures/blocks/cropsCross.png");
        this.textureEmpty = new ResourceLocation(Reference.MOD_ID.toLowerCase()+":textures/blocks/cropsEmpty.png");
    }

    //This method gets called when Minecraft wants to render a crop
    @Override
    public void renderTileEntityAt(TileEntity entity, double x, double y, double z, float f) {
        TileEntityCrop crop = (TileEntityCrop) entity;
       //render the model
        GL11.glPushMatrix();                                                            //initiate first gl renderer
            GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);    //sets the rendering origin to the right spot
            this.setTexture(crop);                                                      //loads the right texture for the model
            GL11.glPushMatrix();                                                        //initiate second gl renderer
                GL11.glRotatef(180, 0F, 0F, 1F);                                        //rotate the renderer so the model doesn't render upside down
                this.model.render(null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);        //actually renders the model
            GL11.glPopMatrix();                                                         //close second gl renderer
        GL11.glPopMatrix();                                                             //close first gl renderer
        if(crop.hasPlant()) {overlay(crop,x,y,z);}                                      //if the crop has a plant, render the plant texture
    }

    //sets the correct texture for the crop
    private void setTexture(TileEntityCrop crop) {
        if(crop.crossCrop) {
            Minecraft.getMinecraft().renderEngine.bindTexture(this.textureCross);
        }
        else {
            Minecraft.getMinecraft().renderEngine.bindTexture(this.textureEmpty);
        }
    }

    //overlays the plant texture
    private void overlay(TileEntityCrop crop,double x,double y,double z) {
        //set up tessellator
        Tessellator tessellator = Tessellator.instance;
        //grab the texture
        ResourceLocation resource = getResource(crop);
        //start GL
        GL11.glPushMatrix();
            GL11.glTranslated(x,y,z);
            //disable lighting so the plants render bright
            GL11.glDisable(GL11.GL_LIGHTING);
            //bind the texture
            Minecraft.getMinecraft().renderEngine.bindTexture(resource);
           drawPlant(tessellator, RenderHelper.getRenderType((ItemSeeds) crop.seed, crop.seedMeta));
        //don't forget to enable lighting again
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glPopMatrix();
    }

    //draws the plant on the crops
    private static void drawPlant(Tessellator tessellator, int renderType) {
        //define 1/16th of a block
        double unit = Constants.unit;
        tessellator.startDrawingQuads();
        if(renderType != 6) {
            //the shift along x and z axis
            double shift = 4*unit;
            //shrink textures
            GL11.glScalef(0.8F, 0.8F, 0.8F);
            //plane 1 front right
            tessellator.addVertexWithUV(0+shift*2, 0, unit * 4, 1, 1);
            tessellator.addVertexWithUV(0+shift*2, 1, unit * 4, 1, 0);
            tessellator.addVertexWithUV(1+shift*2, 1, unit * 4, 0, 0);
            tessellator.addVertexWithUV(1+shift*2, 0, unit * 4, 0, 1);
            //plane 1 front left
            tessellator.addVertexWithUV(0-shift, 0, unit * 4, 1, 1);
            tessellator.addVertexWithUV(0-shift, 1, unit * 4, 1, 0);
            tessellator.addVertexWithUV(1-shift, 1, unit * 4, 0, 0);
            tessellator.addVertexWithUV(1-shift, 0, unit * 4, 0, 1);
            //plane 1 back right
            tessellator.addVertexWithUV(0+shift*2, 0, unit * 4, 1, 1);
            tessellator.addVertexWithUV(1+shift*2, 0, unit * 4, 0, 1);
            tessellator.addVertexWithUV(1+shift*2, 1, unit * 4, 0, 0);
            tessellator.addVertexWithUV(0+shift*2, 1, unit * 4, 1, 0);
            //plane 1 back left
            tessellator.addVertexWithUV(0-shift, 0, unit * 4, 1, 1);
            tessellator.addVertexWithUV(1-shift, 0, unit * 4, 0, 1);
            tessellator.addVertexWithUV(1-shift, 1, unit * 4, 0, 0);
            tessellator.addVertexWithUV(0-shift, 1, unit * 4, 1, 0);
            //plane 2 front right
            tessellator.addVertexWithUV(unit * 4, 0, 0+shift*2, 0, 1);
            tessellator.addVertexWithUV(unit * 4, 0, 1+shift*2, 1, 1);
            tessellator.addVertexWithUV(unit * 4, 1, 1+shift*2, 1, 0);
            tessellator.addVertexWithUV(unit * 4, 1, 0+shift*2, 0, 0);
            //plane 2 front left
            tessellator.addVertexWithUV(unit * 4, 0, 0-shift, 0, 1);
            tessellator.addVertexWithUV(unit * 4, 0, 1-shift, 1, 1);
            tessellator.addVertexWithUV(unit * 4, 1, 1-shift, 1, 0);
            tessellator.addVertexWithUV(unit * 4, 1, 0-shift, 0, 0);
            //plane 2 back right
            tessellator.addVertexWithUV(unit * 4, 0, 0+shift*2, 0, 1);
            tessellator.addVertexWithUV(unit * 4, 1, 0+shift*2, 0, 0);
            tessellator.addVertexWithUV(unit * 4, 1, 1+shift*2, 1, 0);
            tessellator.addVertexWithUV(unit * 4, 0, 1+shift*2, 1, 1);
            //plane 2 back right
            tessellator.addVertexWithUV(unit * 4, 0, 0-shift, 0, 1);
            tessellator.addVertexWithUV(unit * 4, 1, 0-shift, 0, 0);
            tessellator.addVertexWithUV(unit * 4, 1, 1-shift, 1, 0);
            tessellator.addVertexWithUV(unit * 4, 0, 1-shift, 1, 1);
            //plane 3 front right
            tessellator.addVertexWithUV(0+shift*2, 0, 1 - unit * 0, 0, 1);
            tessellator.addVertexWithUV(1+shift*2, 0, 1 - unit * 0, 1, 1);
            tessellator.addVertexWithUV(1+shift*2, 1, 1 - unit * 0, 1, 0);
            tessellator.addVertexWithUV(0+shift*2, 1, 1 - unit * 0, 0, 0);
            //plane 3 front left
            tessellator.addVertexWithUV(0-shift, 0, 1 - unit * 0, 0, 1);
            tessellator.addVertexWithUV(1-shift, 0, 1 - unit * 0, 1, 1);
            tessellator.addVertexWithUV(1-shift, 1, 1 - unit * 0, 1, 0);
            tessellator.addVertexWithUV(0-shift, 1, 1 - unit * 0, 0, 0);
            //plane 3 back right
            tessellator.addVertexWithUV(0+shift*2, 0, 1 - unit * 0, 0, 1);
            tessellator.addVertexWithUV(0+shift*2, 1, 1 - unit * 0, 0, 0);
            tessellator.addVertexWithUV(1+shift*2, 1, 1 - unit * 0, 1, 0);
            tessellator.addVertexWithUV(1+shift*2, 0, 1 - unit * 0, 1, 1);
            //plane 3 back left
            tessellator.addVertexWithUV(0-shift, 0, 1 - unit * 0, 0, 1);
            tessellator.addVertexWithUV(0-shift, 1, 1 - unit * 0, 0, 0);
            tessellator.addVertexWithUV(1-shift, 1, 1 - unit * 0, 1, 0);
            tessellator.addVertexWithUV(1-shift, 0, 1 - unit * 0, 1, 1);
            //plane 4 front right
            tessellator.addVertexWithUV(1 - unit * 0, 0, 1+shift*2, 0, 1);
            tessellator.addVertexWithUV(1 - unit * 0, 0, 0+shift*2, 1, 1);
            tessellator.addVertexWithUV(1 - unit * 0, 1, 0+shift*2, 1, 0);
            tessellator.addVertexWithUV(1 - unit * 0, 1, 1+shift*2, 0, 0);
            //plane 4 front left
            tessellator.addVertexWithUV(1 - unit * 0, 0, 1-shift, 0, 1);
            tessellator.addVertexWithUV(1 - unit * 0, 0, 0-shift, 1, 1);
            tessellator.addVertexWithUV(1 - unit * 0, 1, 0-shift, 1, 0);
            tessellator.addVertexWithUV(1 - unit * 0, 1, 1-shift, 0, 0);
            //plane 4 back right
            tessellator.addVertexWithUV(1 - unit * 0, 0, 1+shift*2, 0, 1);
            tessellator.addVertexWithUV(1 - unit * 0, 1, 1+shift*2, 0, 0);
            tessellator.addVertexWithUV(1 - unit * 0, 1, 0+shift*2, 1, 0);
            tessellator.addVertexWithUV(1 - unit * 0, 0, 0+shift*2, 1, 1);
            //plane 4 back left
            tessellator.addVertexWithUV(1 - unit * 0, 0, 1-shift, 0, 1);
            tessellator.addVertexWithUV(1 - unit * 0, 1, 1-shift, 0, 0);
            tessellator.addVertexWithUV(1 - unit * 0, 1, 0-shift, 1, 0);
            tessellator.addVertexWithUV(1 - unit * 0, 0, 0-shift, 1, 1);
        }
        else {
            //plane 1 front
            tessellator.addVertexWithUV(0, 0, unit * 4, 1, 1);
            tessellator.addVertexWithUV(0, 1, unit * 4, 1, 0);
            tessellator.addVertexWithUV(1, 1, unit * 4, 0, 0);
            tessellator.addVertexWithUV(1, 0, unit * 4, 0, 1);
            //plane 1 back
            tessellator.addVertexWithUV(0, 0, unit * 4, 1, 1);
            tessellator.addVertexWithUV(1, 0, unit * 4, 0, 1);
            tessellator.addVertexWithUV(1, 1, unit * 4, 0, 0);
            tessellator.addVertexWithUV(0, 1, unit * 4, 1, 0);
            //plane 2 front
            tessellator.addVertexWithUV(unit * 4, 0, 0, 0, 1);
            tessellator.addVertexWithUV(unit * 4, 0, 1, 1, 1);
            tessellator.addVertexWithUV(unit * 4, 1, 1, 1, 0);
            tessellator.addVertexWithUV(unit * 4, 1, 0, 0, 0);
            //plane 2 back
            tessellator.addVertexWithUV(unit * 4, 0, 0, 0, 1);
            tessellator.addVertexWithUV(unit * 4, 1, 0, 0, 0);
            tessellator.addVertexWithUV(unit * 4, 1, 1, 1, 0);
            tessellator.addVertexWithUV(unit * 4, 0, 1, 1, 1);
            //plane 3 front
            tessellator.addVertexWithUV(0, 0, 1 - unit * 4, 0, 1);
            tessellator.addVertexWithUV(1, 0, 1 - unit * 4, 1, 1);
            tessellator.addVertexWithUV(1, 1, 1 - unit * 4, 1, 0);
            tessellator.addVertexWithUV(0, 1, 1 - unit * 4, 0, 0);
            //plane 3 back
            tessellator.addVertexWithUV(0, 0, 1 - unit * 4, 0, 1);
            tessellator.addVertexWithUV(0, 1, 1 - unit * 4, 0, 0);
            tessellator.addVertexWithUV(1, 1, 1 - unit * 4, 1, 0);
            tessellator.addVertexWithUV(1, 0, 1 - unit * 4, 1, 1);
            //plane 4 front
            tessellator.addVertexWithUV(1 - unit * 4, 0, 1, 0, 1);
            tessellator.addVertexWithUV(1 - unit * 4, 0, 0, 1, 1);
            tessellator.addVertexWithUV(1 - unit * 4, 1, 0, 1, 0);
            tessellator.addVertexWithUV(1 - unit * 4, 1, 1, 0, 0);
            //plane 4 back
            tessellator.addVertexWithUV(1 - unit * 4, 0, 1, 0, 1);
            tessellator.addVertexWithUV(1 - unit * 4, 1, 1, 0, 0);
            tessellator.addVertexWithUV(1 - unit * 4, 1, 0, 1, 0);
            tessellator.addVertexWithUV(1 - unit * 4, 0, 0, 1, 1);
        }
        tessellator.draw();
    }

    //gets the location for the crop texture from a seed
    private ResourceLocation getResource(TileEntityCrop crop) {
        BlockBush plant = SeedHelper.getPlant((ItemSeeds) crop.seed);
        if(plant!=null) {
            return RenderHelper.getResource(plant, RenderHelper.plantIconIndex((ItemSeeds) crop.seed, crop.seedMeta, crop.getBlockMetadata()));
        }
        else {
            return new ResourceLocation(Reference.MOD_ID.toLowerCase() + "textures/blocks/" + "fileNotFound" + ".png");
        }
    }
}