Loading ...
Sorry, an error occurred while loading the content.

[Cheetahtemplate-discuss] Escape character problem

Expand Messages
  • Saranakom Cheecharoen
    Dear All, ... Temp_FileName = ${COMM_BUS} Pass through ${eDME}_max.pkg t_FileName = Template(Temp_FileName,searchList = [dobj]) Output: A_CAN Pass
    Message 1 of 4 , Jan 17, 2011
    • 0 Attachment

      Dear All,

       

      I use cheetahtemplate to generate file path. Its code look like this:

      ---Test 1---

      Temp_FileName = “${COMM_BUS}\\Pass through\\${eDME}_max.pkg”

      t_FileName = Template(Temp_FileName,searchList = [dobj])

       

      Output:

       

      A_CAN\Pass through${eDME}_max.pkg

      ----End---

       

      Why not they replace for ${eDME}? I think coz backslash is an escape character so cheetah ignore ${eDME} replacement.

      Then I solve it by put more blackslash .

       

      ---Test2---

      Temp_FileName = “${COMM_BUS}\\Pass through\\\${eDME}_max.pkg”

      t_FileName = Template(Temp_FileName,searchList = [dobj])

       

      Output:

       

      A_CAN\Pass through\${eDME}_max.pkg

      ---End---

       

      But it doesn’t work. Just got only backslash output not ${eDME} replacement.

       

      ---Test3---

      Temp_FileName = “${COMM_BUS}\\Pass through\\_${eDME}_max.pkg”

      t_FileName = Template(Temp_FileName,searchList = [dobj])

      Output:

      A_CAN\Pass through\_AgeDegHvsto_min.pkg

      ---End---

       

      For Test3, just to prove that if I put underscore before ${eDME}, it work (replacement) but underscore is not what I want.

       

       

      How I can solve this problem?

       

       

      Best regard,

      Saranakom Cheecharoen

    • Saranakom Cheecharoen
      Dear All, ... Temp_FileName = ${COMM_BUS} Pass through ${eDME}_max.pkg t_FileName = Template(Temp_FileName,searchList = [dobj]) Output: A_CAN Pass
      Message 2 of 4 , Jan 17, 2011
      • 0 Attachment

        Dear All,

         

        I use cheetahtemplate to generate file path. Its code look like this:

        ---Test 1---

        Temp_FileName = “${COMM_BUS}\\Pass through\\${eDME}_max.pkg”

        t_FileName = Template(Temp_FileName,searchList = [dobj])

         

        Output:

         

        A_CAN\Pass through${eDME}_max.pkg

        ----End---

         

        Why not they replace for ${eDME}? I think coz backslash is an escape character so cheetah ignore ${eDME} replacement.

        Then I solve it by put more blackslash .

         

        ---Test2---

        Temp_FileName = “${COMM_BUS}\\Pass through\\\${eDME}_max.pkg”

        t_FileName = Template(Temp_FileName,searchList = [dobj])

         

        Output:

         

        A_CAN\Pass through\${eDME}_max.pkg

        ---End---

         

        But it doesn’t work. Just got only backslash output not ${eDME} replacement.

         

        ---Test3---

        Temp_FileName = “${COMM_BUS}\\Pass through\\_${eDME}_max.pkg”

        t_FileName = Template(Temp_FileName,searchList = [dobj])

        Output:

        A_CAN\Pass through\_AgeDegHvsto_min.pkg

        ---End---

         

        For Test3, just to prove that if I put underscore before ${eDME}, it work (replacement) but underscore is not what I want.

         

         

        How I can solve this problem?

         

         

        Best regard,

        Saranakom Cheecharoen

      • Jean-Baptiste Quenot
        This is a very creative way of using Cheetah, congratulations! No, seriously, I would use Python s built-in dictionary-style string ... A_CAN Pass
        Message 3 of 4 , Feb 21, 2011
        • 0 Attachment
          This is a very creative way of using Cheetah, congratulations!

          No, seriously, I would use Python's built-in dictionary-style string
          formatting for this:

          >>> "%(COMM_BUS)s\\Pass through\\%(eDME)s_max.pkg" % {'COMM_BUS': 'A_CAN', 'eDME': '123'}
          'A_CAN\\Pass through\\123_max.pkg'
          --
          Jean-Baptiste Quenot

          ------------------------------------------------------------------------------
          The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
          Pinpoint memory and threading errors before they happen.
          Find and fix more than 250 security defects in the development cycle.
          Locate bottlenecks in serial and parallel code that limit performance.
          http://p.sf.net/sfu/intel-dev2devfeb
          _______________________________________________
          Cheetahtemplate-discuss mailing list
          Cheetahtemplate-discuss@...
          https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
        • Saranakom Cheecharoen
          Thanks, Jean-Baptiste Quenot. I have many things to learn more in Python. Regards, Long ... From: caraldi@gmail.com [mailto:caraldi@gmail.com] On Behalf Of
          Message 4 of 4 , Feb 21, 2011
          • 0 Attachment
            Thanks, Jean-Baptiste Quenot.

            I have many things to learn more in Python.

            Regards,
            Long

            -----Original Message-----
            From: caraldi@... [mailto:caraldi@...] On Behalf Of
            Jean-Baptiste Quenot
            Sent: Monday, February 21, 2011 11:46 PM
            To: Saranakom Cheecharoen
            Cc: cheetahtemplate-discuss@...
            Subject: Re: [Cheetahtemplate-discuss] Escape character problem

            This is a very creative way of using Cheetah, congratulations!

            No, seriously, I would use Python's built-in dictionary-style string
            formatting for this:

            >>> "%(COMM_BUS)s\\Pass through\\%(eDME)s_max.pkg" % {'COMM_BUS':
            >>> 'A_CAN', 'eDME': '123'}
            'A_CAN\\Pass through\\123_max.pkg'
            --
            Jean-Baptiste Quenot


            ------------------------------------------------------------------------------
            Index, Search & Analyze Logs and other IT data in Real-Time with Splunk
            Collect, index and harness all the fast moving IT data generated by your
            applications, servers and devices whether physical, virtual or in the cloud.
            Deliver compliance at lower cost and gain new business insights.
            Free Software Download: http://p.sf.net/sfu/splunk-dev2dev
            _______________________________________________
            Cheetahtemplate-discuss mailing list
            Cheetahtemplate-discuss@...
            https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
          Your message has been successfully submitted and would be delivered to recipients shortly.